无法使用Sequelize更新属于许多

时间:2019-05-28 02:43:43

标签: javascript sequelize.js

我是续集的新手,我已经成功创建了许多记录,但更新记录存在问题。

Customer.update({
  cid: req.body.cid,
  pass: req.body.pass,
  name: req.body.name,
  address: req.body.address,
  cnic: req.body.cnic,
  mobile: req.body.mobile,
  packageid: req.body.packageid,
  status: req.body.status,
  active_dt: req.body.active_dt,
  exp_dt: req.body.exp_dt,
  payment: req.body.payment,
  bal: req.body.bal
}, 
{
  where: {
    id: req.params.id
  }
}).then(Custom => {
  Package.findAll({
    where: {    
      pname: {
        [Op.or]: req.body.packname
      }
    }
  }).then(packname => {
  Custom.setPackageRef(packname).then(() => {
    res.send({ message: 'Update successfully!' });
  });
  }).catch(err => {
    res.status(500).send({ reason: err.message });
});
}).catch(err => {
  res.status(500).send({ reason: err.message });
})

}

错误:不是函数“ Custom.setPackageRef” 但相同的参数在创建记录中工作正常

0 个答案:

没有答案