mongodb,给所有的数据加上一个字段“mark”。需要把multi这个option设为true,才可以批量。
db.getCollection('xxx').update(
// query
{
//"key" : "value"
},
// update
{
$set:{"mark":""}
},
// options
{
"multi" : true, // update only one document
"upsert" : false // insert a new document, if no existing document match the query
}
);
复制代码