- MongoDB CRUD Operations >
- Update Documents >
- Update Methods
Update Methods¶
MongoDB provides the following methods for updating documents in a collection:
db.collection.updateOne() |
Updates at most a single document that match a specified filter even though multiple documents may match the specified filter. |
db.collection.updateMany() |
Update all documents that match a specified filter. |
db.collection.replaceOne() |
Replaces at most a single document that match a specified filter even though multiple documents may match the specified filter. |
Additional Methods¶
The following methods can also update documents from a collection:
db.collection.findOneAndReplace()
.db.collection.findOneAndUpdate()
.db.collection.findAndModify()
.db.collection.bulkWrite()
.
See the individual reference pages for the methods for more information and examples.