我想知道如何使用 node.js 和 sequelize 更新关联模型。
我正在尝试更新联合 (BelongsTo) 类别表。
Review.belongsTo(models.Category, {foreignkey : 'CategoryId', 约束: false});
/** * Update a review */ exports.update = function(req, res) {
// create a new variable to hold the review that was placed on the req object.
var review = req.review;
review.updateAttributes({
reviewed : req.body.reviewed,
Category.metaTitle : req.body.Category.metaTitle
}).then(function(a){
return res.jsonp(a);
}).catch(function(err){
return res.render('error', {
error: err,
status: 500
});
}); };
最佳答案
改变这个
Category.metaTitle : req.body.Category.metaTitle to
Category : req.body.Category.metaTitle
关于angularjs - Angular、Sequelize、Nodejs 更新关系模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37612391/