The update operation

The following is a list of methods MongoDB uses to update the document information:

* db.collection.updateOne(<filter>, <update>, <options>);* db.collection.updateMany(<filter>, <update>, <options>);* db.collection.replaceOne(<filter>, <update>, <options>);

If the update operation increases the size of the document while updating, the update operation relocates the document on the disk:

  • Update single document: The following example uses the db.collection.updateOne() method to update a single document. The following query finds the userId 1 document in user_profiles and updates the age to 30:

Here, the query uses the  ...

Get Seven NoSQL Databases in a Week now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.