使用sequelize,你如何使用or运算符与where标准?

从以前的SO讨论中,我能够用两个条件更新多个续集实例。

任何人都可以解释如何使用逻辑OR运算符而不是AND运算符来修改sequelize .update方法吗? 以下是使用AND进行更新的两种情况的续集更新方法。

global.db.Task.update( {Desc: 'New Upate'}, //set attribute {cd: 'match', Desc: null} //where criteria ).success(function(affectedRows) { ... }); 

这将读取一个SQL语句如下:

 UPDATE "Task" SET "Desc"='New Update' WHERE "Cd"='match' AND "Desc" IS NULL 

尝试

 global.db.Task.update( {Desc: 'New Upate'}, //set attribute ["cd = ? OR Desc = ?", 'match', null] //where criteria ).success(function(affectedRows) { ... }); 

更新 (来自Miller):在设置的属性行末尾添加了一个逗号。

global.db.Task.update({update_data},{where:{where_data}})。then(function(affectedrows){})

  global.db.Task.update({Desc: 'New Upate'}, where: {$or: [{cd: "match"}, {Desc: null}]}).success(function(affectedRows) { ... });