Delete Document MongoDB

Delete Document MongoDB

Instructor-svgAl-Mamun Sarkar
Sep 11 , 2020

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({})

 

  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram