The remove() method of a MongoDB collection is used to delete documents from that collection. The remove() method takes a "delete criteria" document and an optional "remove options" document as parameters


db.CollectionName.remove({delete_criteria}, {justOne: <boolean>, writeConcern: {<document>} } )

{ delete_criteria }

The delete_criteria parameter is a document that specifies the condition used to select the documents for deletion. An empty query document ({}) will delete all documents in the collection.

Optionally you can pass a "remove options" document to the remove() method. The remove options document can have two parameters:


This is an optional parameter and can be set to either true or false. If set to true, only one document that match the delete criteria is deleted. The default value is false which will delete all documents that match the delete criteria.


The writeConcern parameter is optional and it is used to specify the write concern which is the level of guarantee that MongoDB provides for a write operation.


The following example removes documents whose title field has the value The book thief in the movie collection.

>{"title" : "The book thief"});
Last Updated: 02-September-2014

Post a comment


Your Comment

Email (We dont publish it)


Nothing the first to share wisdom.