You can perform bulk delete operations on multiple documents in Atlas by using the Delete Documents modal. This helps you visualize deletes before applying them.
About this Task
Deleting documents is a permanent action and cannot not be undone. Validate documents in the Preview of the Delete Documents modal before confirming the delete operation.
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 Delete Documents modal
On the Documents tab, click the Delete button to display the Delete Documents modal. The following table summarizes the UI of the modal:
UI Element | Description |
|---|---|
Query | Any filter criteria specified on the Query Bar applies to the Delete Documents modal. To update the Query, exit the Delete Documents modal and modify the query in the Query Bar. |
Export | Opens the Export Delete Query To Language modal, where you can convert the query to a supported driver language. |
Preview | A preview of the documents that will be deleted. |
(Optional) Export the Delete
You can export the Delete query to a supported driver language using the Export button on the Delete Documents modal.
On the Delete Documents modal, click Export. The Export Delete Query To Language modal displays with the delete syntax populated under My Delete Query.
Select a programming language from the drop-down under Exported Delete Query. You can convert the command to C#, Go, Java, Node, PHP, Python, Ruby, or Rust. The field below displays the converted syntax.
(Optional) Click the Include Import Statements checkbox to include the required import statements for the selected programming language.
Click the icon to copy the converted syntax.
Click Close.
Example
The following example deletes two documents from
the movies collection in the sample_mflix dataset.
In the Query Bar, enter a filter for movies
with a year of 1919.
{ 'year' : 1919 }
Click the Delete button, the Delete Documents modal displays.
The Preview pane shows the documents included in the delete operation.
Click Delete Documents. A confirmation modal displays.
Click the red Delete Documents button to confirm the operation.