2015-10-06 46 views
0

如何在Sequelize中创建推送值,类比SQL请求UPDATE table SET fields = fields + 'test'续集推送值

例子:

table.find({where: {id: 1}}).then(function(result) { 
    console.log(result.name); //returned 'abc' 
}) 

//actions (+ 'test') 

table.find({where: {id: 1}}).then(function(result) { 
    console.log(result.name); //returned 'abctest' 
}) 

(对不起,我英文不好)

回答

0
table.find({where: {id: 1}}).then(function(result) { 
    result.name = result.name + 'test'; 
    result.save(); 
}) 
0

假如你有良好的格式化的请求的所有参数可以更新任何像这样的表值:

table.update(req.body, 
      {where: { id: 1 } } 
     ) 
     .then(() => { 
      //some other stuff 
     }) 
     .catch(app.error);