MongoDB's remove() method is used to remove document from the collection.
remove() method accepts two parameters.
The syntax of remove() method is as follows
>db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)
The following code will remove all the documents whose title is 'MongoDB Overview'.
>db.mycol.remove({'title':'MongoDB Overview'}) >
To delete only first record, set justOne
parameter in remove() method.
>db.COLLECTION_NAME.remove(DELETION_CRITERIA,1)
If you don't specify deletion criteria, MongoDB will delete all documents from the collection. This is equivalent of SQL's truncate command.
>db.mycol.remove() >db.mycol.find() >