MongoDB Delete documentsIn MongoDB, the db.colloction.remove() method is used to delete documents from a collection. The remove() method works on two parameters. 1. Deletion criteria: With the use of its syntax you can remove the documents from the collection. 2. JustOne: It removes only one document when set to true or 1. Syntax: Remove all documentsIf you want to remove all documents from a collection, pass an empty query document {} to the remove() method. The remove() method does not remove the indexes. Let's take an example to demonstrate the remove() method. In this example, we remove all documents from the "javatpoint" collection. Remove all documents that match a conditionIf you want to remove a document that match a specific condition, call the remove() method with the <query> parameter. The following example will remove all documents from the javatpoint collection where the type field is equal to programming language. Remove a single document that match a conditionIf you want to remove a single document that match a specific condition, call the remove() method with justOne parameter set to true or 1. The following example will remove a single document from the javatpoint collection where the type field is equal to programming language. Next TopicMongoDB Query Documents |