使用mongojs,我们需要使用下面给出的代码
更新文档db.data.update(
{
"title": {$regex : '.*Green Red.*', $options : 's'},
"editor.key": {"$in": ["74014","45339"]},`enter code here`
"types" : "Notes"
},
{
$set: {
"editor.key": "05335",
"editor.value": "editor1",
"editor.email": "editor1@gmail.com"
}
},
false,
true
);
但问题是它真的不是动态的
exports.updatePerson = function(Person , onDone) {
Person.UpdatedOn = new Date();
db.people.save(nodd, function (err) {
onDone();
});
但它创建了重复记录
答案 0 :(得分:1)
试试这个:
db.data.update(
{
"title": {$regex : '.*Green Red.*', $options : 's'},
"editor.key": {"$in": ["74014","45339"]},`enter code here`
"types" : "Notes"
},
{
$set: {
"editor.key": "05335",
"editor.value": "editor1",
"editor.email": "editor1@gmail.com"
}
},{
insert:false,
multi : true
}
);
insert和multi参数应该是对象的字段