Delete Document MongoDB

Author: Al-mamun Sarkar Date: 2020-09-11 14:44:58

In this lesson, I will show you how to delete single or multiple documents from the collection of the MongoDB database. 

 

Delete Query:

Syntax:

db.collection.remove(condition, just_one)

Example:

db.employees.remove({email: 'tamim@gmail.com'})

 

Delete Just One Row:

db.employees.remove({salary: {$lt: 800}}, 1)

 

Delete all documents (SQL's truncate):

db.employees.remove({})