我正在使用sequelize包含使用此命令 Complaint.belongsTo(Store);
我将 req.body 改为:
req.body===========> { id: 2,
cno: 100,
dt: '2017-07-25T20:49:36.000Z',
cname: 'feugiat',
product: 'posuere at, velit. Cras lorem lorem, luctus ut, pellentesque',
brand: 'lobortis quam a felis',
shop: '$2a$10$J4taP8HVULiBaLE51o8QW.hYG6VUUjxzCpoDnoYDFAXWjmUbGexja',
status: 'Unassigned',
rid: 1,
cmbno: '(234) 341-9792',
cemail: 'velit@convallisestvitae.org',
desc: 'cursus. Integer mollis. Integer tincidunt aliquam arcu. Aliquam ultrices iaculis',
req: null,
isActive: true,
activity: '2018-04-11T06:23:34.000Z',
createdAt: '2017-05-27T03:40:27.000Z',
updatedAt: '2018-10-07T20:56:20.000Z',
adminId: null,
storeId: [ 14, 15, 16 ],
serviceId: null,
admin: null,
store: null,
service: null }
我将 storeId 值设为 storeId:[14,15,16] 。
然后我得到服务器端错误=> POST / api / needrequest /:id 400 ,
我的api:
exports.needRequest = function(req, res) {
console.log('the data===========>',req.body);
Complaint.update(req.body, {
where: {
id: req.body.id
}
}).then(function(data) {
console.log('include', req.body);
Complaint.findAll({
where: {
id: req.params.id
},
include: [{
model: Admin,
}, {
model: Store,
}, {
model: Service,
}]
})
}).then(function(data) {
return res.status(200).send(data);
}).catch(Sequelize.ValidationError, function(err) {
return res.status(422).send(err.errors[0].message);
}).catch(function(err) {
return res.status(400).send(err.message);
});
};
我如何更新?
请给出任何解决方案!