Docs Menu
Docs Home
/
MongoDB Compass
/ /

Delete Multiple Documents

On this page

  • About this Task
  • Before you Begin
  • Steps
  • Example
  • Learn More

You can perform bulk delete operations on multiple documents in Compass by using the Delete Documents modal. This helps you visualize deletes before applying them.

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.

The Delete Documents modal is available starting in Compass version 1.42.0. For instructions on updating or installing the latest Compass version, see Download and Install Compass.

1

From the Documents tab, input a query into the Query Bar to filter deleted documents. To delete all documents in the collection, leave the Query Bar blank.

2

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.
3

You can export the Delete query to a supported driver language using the Export button on the Delete Documents modal.

  1. On the Delete Documents modal, click Export. The Export Delete Query To Language modal displays with the delete syntax populated under My Delete Query.

  2. 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.

  3. (Optional) Click the Include Import Statements checkbox to include the required import statements for the selected programming language.

  4. Click the icon to copy the converted syntax.

  5. Click Close.

4
  1. On the Delete Documents modal, click Delete Documents.

  2. Click the red Delete Documents button to confirm the operation.

Compass deletes the documents that match the filter expression.

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.

Back

Delete Single Document

Next

Query Your Data