MongoDB

Remove Documents using Mongo Shell

The db.collection.remove() method removes documents from a collection.

  • You can remove all documents from a collection.
  • Remove all documents that match a condition.
  • Or limit the operation to remove just a single document.
 db.users.remove({})  //Remove All Documents  
db.users.remove({Name : "Himen Patel" }) //Remove Documents that Match a Condition
db.users.remove({Name : "Himen Patel" },1 ) //Remove a Single Document that Matches a Condition

Leave a comment