In this chapter, we will explain how to delete a document using MongoDB.
MongoDB's remove() method is used for removing a document from the collection. remove() method will accept two parameters. One is deletion criteria and the second is justOne flag.
Basic syntax of remove() method is as follows
Consider mycol collection has the following data.
Below example removes all the documents whose title is 'MongoDB Overview'.
If there are multiple records and if you want to delete only the first record, then set justOne parameter in remove() method.
If a deletion criterion is not specified, then MongoDB will delete entire documents from the collection. This is equivalent of SQL's truncate command.
MongoDB Related Interview Questions
|Python Interview Questions||C & Data Structures Interview Questions|
|Hadoop Interview Questions||Node.js Interview Questions|
|Scala Interview Questions||Socket Programming Interview Questions|
|HBase Interview Questions||Solaris Administrator Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.