Overview of deleting Recordsin MongoDB, the Db.collection.remove () method is used to delete records in the collection. You can delete all records, delete all eligible records, or delete only one record.
Delete all recordsdeletes all the records in a collection as long as an empty query object {} is passed to the Remove () method. The Remove () method does not delete the index.
Example:db.testData.remove ({});
using the Remove () method to delete all records in a collection may be more efficient than deleting the entire collection containing the index using the drop () method, and then rebuilding the collection and index.
Delete a record that matches a condition removes all eligible records from a collection, passing a query object to the Remove () method.
Example:db.testData.remove ({type: ' food '}); Records that all type fields will be deleted
for a large-scale delete operation, the Remove () operation may be more efficient if you want to copy some records into a new collection and then delete the entire collection with the drop () method.
Delete a single record that matches a condition to delete a record in a collection that matches a condition, you need to give the Remove () method a Justone parameter, set to Ture or 1
Example:db.testData.remove ({type: ' food '},1);
to delete a record in a collection that is arranged in a certain order, use the Findandmodify () method.
MongoDB Operations Manual Crud Remove Remove