MongoDB – Delete Document:

In MongoDB, deleting a document can be done through below provided methods.

Syntax:

db.collection.deleteOne() --> New in version 3.2.

This command will delete a single document even though the filter or condition have multiple document that may match to update.

db.collection.deleteMany() --> New in version 3.2.

This command will delete all documents that match the condition.

db.collection.remove()

This command can delete either a single document or multiple documents that match the condition.

Example:

db.students.remove(
{ "firstname": "Manju" }
)