Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm very new to MongoDB and MongoDB Compass.

I have some 1000 records in a customer collection. How I can delete all the records at once through MongoDB compass.

Many Thanks,

like image 773
anil Avatar asked May 21 '18 12:05

anil


People also ask

How do I remove all records from a collection in MongoDB?

To delete all documents in a collection, pass an empty document ( {} ). Optional. To limit the deletion to just one document, set to true . Omit to use the default value of false and delete all documents matching the deletion criteria.

How do I delete multiple records in MongoDB Atlas?

You actually can't bulk delete in MongoDB Atlas. See MongoDB Atlas info on the filter section AKA Data Explorer. However you can run standard queries, like find, remove once you connect to the database using your Atlas credentials.

Which method is used to delete a collection in MongoDB?

MongoDB's remove() method is used to remove a document from the collection. remove() method accepts two parameters. One is deletion criteria and second is justOne flag. deletion criteria − (Optional) deletion criteria according to documents will be removed.


Video Answer


1 Answers

You can use Embedded Shell provided by the MongoDB compass. Its in beta mode right now. I am using compass version 1.23.0

MongoDB compass with Shell

To delete multiple records, you can use db.<collectionname>.deleteMany
https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/

like image 87
Muhammad Tariq Avatar answered Oct 13 '22 22:10

Muhammad Tariq