MongoDB 8 · Create, read, update, delete
Delete many documents
Delete every document that matches the filter.
db.users.deleteMany({ active: false })
Caution: An empty filter {} deletes every document in the collection. Test the filter with find() first.
Official MongoDB 8 documentation
More create, read, update, delete commands
- Insert a document
- Insert several documents
- Find all documents
- Find with a filter and projection
- Find one document
- Sort and paginate
All create, read, update, delete commands · MongoDB 8 cheatsheet