Tough Document Replacement Update operation
Db. [Documentname].update ({finder},{modifier})
2. The primary key conflict will error and stop the update operation, when the hard-to-replace document and the existing document ID conflict, the system will error
Example:
> Db.userInfo.find () {"_id": 2, "name": "Xiaoyou"} {"_id": 3, "name": "yy"}> db.userInfo.update ({_id:2},{_id:3 , Name: "QQ"}) Writeresult ({"nmatched": 0, "nupserted": 0, "nmodified": 0, "Writeerror": {"code": 16837, "errmsg": "The _id field cannot is changed from {_id:2.0} to {_id:3.0}. "}})
3.inserOrUpdate operation (the third parameter defaults to false)
Db. [Documenname].update ({finder},{modifier},true)
4. Batch update operation, by default when the query query more than one data, the default is to modify the first data if the implementation of bulk modification
Db. [Documnetname].update ({finder},{modifier},false,true)
5. Use the modifier to complete the local update operation
MongoDB Note 2 (Basic operations, additions and deletions)