Angular,Sequelize,Nodejs更新关系模型

时间:2016-06-03 10:48:14

标签: angularjs node.js sequelize.js mean-stack

我想知道如何使用node.js和sequelize更新关联的模型。

我正在尝试更新关节(BelongsTo)类别表。

Review.belongsTo(models.Category,{foreignkey:'CategoryId',constraints: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
        });
    }); };

1 个答案:

答案 0 :(得分:0)

更改此

 Category.metaTitle          : req.body.Category.metaTitle to
Category : req.body.Category.metaTitle