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,
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.
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.
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.
You can use Embedded Shell provided by the MongoDB compass. Its in beta mode right now. I am using compass version 1.23.0
To delete multiple records, you can use db.<collectionname>.deleteMany
https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With