Python Tutorials · Python MongoDB
MongoDB Delete
Learn all about MongoDB Delete in this comprehensive tutorial.
5 min read advanced
- •To delete one document, we use the delete_one() method.
- •To delete more than one document, use the delete_many() method.
- •To delete all documents in a collection, pass an empty query object to the delete_many() method:
Delete Document
To delete one document, we use the delete_one() method.
The first parameter of the delete_one() method is a query object defining which document to delete.
Note: Note: If the query finds more than one document, only the first
occurrence is deleted.
python
Delete Many Documents
To delete more than one document, use the delete_many() method.
The first parameter of the delete_many() method is a query object defining which documents to delete.
python
Delete All Documents in a Collection
To delete all documents in a collection, pass an empty query object to the delete_many() method:
python
Module quiz
2 questions1
Which of the following is true about MongoDB Delete?
2
What is the most common pitfall when working with MongoDB Delete?
Answer all questions to submit.