Sequelize - update record, and return result

后端 未结 7 894
粉色の甜心
粉色の甜心 2020-12-28 11:20

I am using sequelize with MySQL. For example if I do:

models.People.update({OwnerId: peopleInfo.newuser},
        {where: {id: peopleInfo.scenario.id}})
             


        
7条回答
  •  感动是毒
    2020-12-28 12:07

    Finally i got it. returning true wont work in mysql , we have to use findByPk in order hope this code will help.

           return new Promise(function(resolve, reject) {
    User.update({
            subject: params.firstName, body: params.lastName, status: params.status
        },{
            returning:true,
            where: {id:id }                             
        }).then(function(){
            let response = User.findById(params.userId);                      
            resolve(response);
        }); 
    

    });

提交回复
热议问题