Docs Menu

Docs HomeMongoDB Manual

Update Methods

MongoDB provides the following methods for updating documents in a collection:

Updates at most a single document that match a specified filter even though multiple documents may match the specified filter.

New in version 3.2.

Update all documents that match a specified filter.

New in version 3.2.

Replaces at most a single document that match a specified filter even though multiple documents may match the specified filter.

New in version 3.2.

Either updates or replaces a single document that match a specified filter or updates all documents that match a specified filter.

By default, the db.collection.update() method updates a single document. To update multiple documents, use the multi option.

The following methods can also update documents from a collection:

See the individual reference pages for the methods for more information and examples.

←  Updates with Aggregation PipelineDelete Documents →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.