Update Documents
- Mongo Shell
- Compass
- Python
- Java (Sync)
- Node.js
- Other
This page provides examples of how to update documents in using the following methods in the mongo
shell:
db.collection.updateOne(<filter>, <update>, <options>)
db.collection.updateMany(<filter>, <update>, <options>)
db.collection.replaceOne(<filter>, <replacement>, <options>)
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents in MongoDB Compass .
The examples on this page use the inventory
collection. Populate the inventory
collection with the following documents:
This page provides examples of how to update documents using the following methods in the PyMongo Python driver:
pymongo.collection.Collection.update_one()
pymongo.collection.Collection.update_many()
pymongo.collection.Collection.replace_one()
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the Java Synchronous Driver :
- com.mongodb.client.MongoCollection.updateOne
- com.mongodb.client.MongoCollection.updateMany
- com.mongodb.client.MongoCollection.replaceOne
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the MongoDB Node.js Driver :
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the MongoDB PHP Library :
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the Motor driver:
motor.motor_asyncio.AsyncIOMotorCollection.update_one()
motor.motor_asyncio.AsyncIOMotorCollection.update_many()
motor.motor_asyncio.AsyncIOMotorCollection.replace_one()
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the Java Reactive Streams Driver :
- com.mongodb.reactivestreams.client.MongoCollection.updateOne
- com.mongodb.reactivestreams.client.MongoCollection.updateMany
- com.mongodb.reactivestreams.client.MongoCollection.replaceOne
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the MongoDB C# Driver :
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the MongoDB Perl Driver :
- MongoDB::Collection::update_one()
- MongoDB::Collection::update_many()
- MongoDB::Collection::replace_one()
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the MongoDB Ruby Driver :
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
This page provides examples of how to update documents using the following methods in the MongoDB Scala Driver :
The examples on this page use the inventory
collection. To create and/or populate the inventory
collection, run the following:
- Mongo Shell
- Compass
- Python
- Java (Sync)
- Node.js
- Other
You can run the operation in the web shell below:
https://mws.mongodb.com/?version=3.6