mongodb shell 更新多条记录

db.version()
3.0.5

用update更新满足条件的多条记录时,需要设置 multi:true。

例子:

db.collection.update({},{$set:{“isSend”:false,”sendCount”:0}},{upsert:false,multi:true});

upsert参数的含义:

可选参数,如果没有查询到记录,则新插入一条新的document记录。默认为false。

Optional. If set to true, creates a new document when no document matches the query criteria. The default value is false, which does not insert a new document when no match is found.

multi参数的含义:

更新多条记录

Optional. If set to true, updates multiple documents that meet the query criteria. If set to false, updates one document. The default value is false. For additional information, see Multi Parameter.

此篇文章已被阅读2208 次

Tags:

Add a Comment

邮箱地址不会被公开。 必填项已用*标注