MongoDB provides the following methods for updating documents in a collection:MongoDB提供以下方法来更新集合中的文档:
db.collection.updateOne() |
|
db.collection.updateMany() |
|
db.collection.replaceOne() |
|
db.collection.update() |
|
The following methods can also update documents from a collection:以下方法还可以更新集合中的文档:
db.collection.findOneAndReplace()
.db.collection.findOneAndUpdate()
.db.collection.findAndModify()
.db.collection.save()
.db.collection.bulkWrite()
.See the individual reference pages for the methods for more information and examples.有关更多信息和示例,请参阅各个参考页中的方法。