关于node-mongodb的参数
发布于 10 年前 作者 bluedream 4000 次浏览 最后一次编辑是 8 年前
collection.update(criteria, objNew, options, [callback]);

Useful options:

  • safe:true Should always set if you have a callback.

  • multi:true If set, all matching documents are updated, not just the first.

  • upsert:true Atomically inserts the document if no documents matched.

 db.collection('test').update({hi: 'here'}, {$set: {hi: 'there'}}, {w:1},    
 function(err) {
   if (err) console.warn(err.message);
   else console.log('successfully updated');
});

README文档里给的是safe multi upsert这几个选项。 但这个{w:1}是啥意思,哪里能看到相关文档说明?

地址: node-mongodb

回到顶部