MongoDb Document remove by Python

You can remove a particular record using the pymongo module. In order to test remove functionality of Pymongo, We will use another JSON file.
Click to view JSON File
Insert this JSON document in the Mongodb, as shown in MongoDb Insert We made a new collection named book_collection3.
Python MongoDB Document
MongoDb document

I am going to give the minimum required code to delete the record. The below code would delete the records containing ID=1
Python MongoDB Document deletion
MongoDb document deletion
Click to view code
Out-put of code.
Python MongoDB Document deletion Out-put
MongoDb document deletion Output
The above out-put shows, Three records of ID=1 have been deleted.
Let us check the out-put of MongoDB
Python MongoDB Document after deletion
Python MongoDB Document after deletion
You can see that no record, which contain ID=1 are left.

Remove all records

In order to remove all records use following code line.
result = record1.remove({ })