Docs Menu

Docs HomeDevelop ApplicationsMongoDB DriversNode.js Driver

Update Multiple Documents

You can update multiple documents using the collection.updateMany() method. The updateMany() method accepts a filter document and an update document. If the query matches documents in the collection, the method applies the updates from the update document to fields and values of the matching documents. The update document requires an update operator to modify a field in a document.

You can specify more options in the options object passed in the third parameter of the updateMany() method. For more detailed information, see the updateMany() API documentation.

Note

You can use this example to connect to an instance of MongoDB and interact with a database that contains sample data. To learn more about connecting to your MongoDB instance and loading a sample dataset, see the Usage Examples guide.

Running the preceding example, you see the following output:

Updated 477 documents
←  Update a DocumentReplace a Document →