Deleting Documents from a Collection
At times you may need to delete documents from your MongoDB collection to control space consumption, improve performance, and keep things clean. The remove()
method on Collection
objects makes it very simple to delete documents from a collection. The syntax for the remove()
method is shown below:
remove([query], [options], [callback])
The query
parameter is a document that is used to identify which document(s) you want to delete. The request matches the properties and values in query
with the fields and values of the object, and only those that match the query are updated. If no query
is provided, then all the documents in the collection are deleted.
The options
parameter specifies ...
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.