Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Mongo Compass include Delete many documents at one time function?

Tags:

mongodb

I'm using MongoDB for a while with my projects. But Um currently New to MongoDB compass application. so When I want to delete a lot of documents at a time . How will I perform that operation in Mongo Compass ?

like image 626
Lahiru Malepathirana Avatar asked Sep 07 '18 05:09

Lahiru Malepathirana


4 Answers

While searching for shell option with MongoDB Compass, I come to know that compass also provides built-in shell which can be used to execute MongoDB commands. Please check my answer below for more information.

How to delete selected multiple records in a collection in MongoDB using MongoDB compass

Cheers,

like image 76
Muhammad Tariq Avatar answered Oct 23 '22 05:10

Muhammad Tariq


A workaround in Compass, drop the collection first and then create the collection with the same name, or even import some sample document.

like image 38
YourBestBet Avatar answered Oct 23 '22 07:10

YourBestBet


The only way [until release 1.20.5], is to execute the delete command from mongo-shell.
Here are the steps and example to delete multiple documents matching a filter, using a mongo-shell

  1. download mongo-shell from the link
  2. Open the command-prompt and navigate to the folder where binary files are present
  3. Connect to mongo-server, Run the connection command > mongo "mongodb+srv://cluster-name.mongodb.net/db_name" --username <uasername> --password <password>
  4. example delete command, run : db.users.remove( { status : "P" } ) to remove all documents from the users collection where the status field equals "P"
like image 42
Remis Haroon - رامز Avatar answered Oct 23 '22 05:10

Remis Haroon - رامز


Latest stable version of Compass (1.16.3) does not support a delete many operation. To do that, you need to use the mongo shell - https://docs.mongodb.com/v3.2/tutorial/remove-documents/

like image 40
H. Opler Avatar answered Oct 23 '22 05:10

H. Opler