Tutorials References Exercises Sign Up Menu
Create Website Get Certified Pro

MongoDB mongosh Delete

Delete Documents

We can delete documents by using the methods deleteOne() or deleteMany().

These methods accept a query object. The matching documents will be deleted.


The deleteOne() method will delete the first document that matches the query provided.


db.posts.deleteOne({ title: "Post Title 5" })
Try it Yourself »


The deleteMany() method will delete all documents that match the query provided.


db.posts.deleteMany({ category: "Technology" })
Try it Yourself »