You can perform bulk update operations on multiple documents in Atlas by using the Update Documents modal. Performing updates with the Update Documents modal helps you visualize updates to your data before you apply them.
About this Task
You can use any syntax that works with the
updateparameter ofdb.collection.updateMany().The Update Documents modal does not support any
optionsparameters such as upsert, writeConcern, or collation.Previews of the documents affected by bulk update operations are only visible if your database is configured to support transactions. For details, see /core/transactions.
Steps
In Atlas, go to the Data Explorer page for your project.
If it's not already displayed, select the organization that contains your project from the Organizations menu in the navigation bar.
If it's not already displayed, select your project from the Projects menu in the navigation bar.
In the sidebar, click Data Explorer under the Database heading.
The Data Explorer displays.
Note
You can also go to the Clusters page, and click Data Explorer under the Shortcuts heading.
Open the bulk update modal
On the Documents tab, click the Update button to display the Update Documents modal. The following table summarizes the UI of the modal:
UI Element | Description |
|---|---|
Filter | Any filter criteria specified on the Query Bar applies to the Update Documents modal. To update the filter query, exit the Update Documents modal and modify the query in the Query Bar. |
Update | The update syntax that is applied to the
documents specified in the filter criteria. You can use
any syntax that works with the |
Preview | A preview of documents with the update syntax applied. |
Example
The following example uses the sample_mflix dataset.
This example updates the tomatoes.viewer.numReviews and
tomatoes.viewer.meter fields with the Atlas
Update Documents modal.
Apply a filter in the Query Bar to filter movies which
have a year of 1917.
{ 'year' : 1917 }
Click the Update button, the Update Documents modal displays.
In the Update text box, paste the following syntax:
{ $inc: { "tomatoes.viewer.numReviews" : 1}, $set: { "tomatoes.viewer.meter" : 99 } }
This syntax:
Increments the
tomatoes.viewer.numReviewsfield by1.Sets the
tomatoes.viewer.meterfield to99.
The Preview section populates with sample documents affected by the update query.
To view the updates to the numReviews and meter fields:
Click the arrow icon next to tomatoes.
Click the arrow icon next to viewer.
Click the Update Documents button to update the collection's data.