How to delete document from MongoDB using Mongoengine? I'veread the API reference here:
http://docs.mongoengine.org/apireference.html
but I can not understand what is:
delete(**write_concern)
Do you have any idea?
You can either delete an single Document instance by calling its delete method: lunch = Food. objects. first() // Get a single 'Food' instance lunch.
By default, remove() removes all documents that match the query expression. Specify the justOne option to limit the operation to removing a single document. To delete a single document sorted by a specified order, use the findAndModify() method.
To delete all documents in a collection, pass an empty document ({}). To limit the deletion to just one document, set to true. Omit to use the default value of false and delete all documents matching the deletion criteria.
You can either delete an single Document
instance by calling its delete method:
lunch = Food.objects.first() // Get a single 'Food' instance lunch.delete() // Delete it!
Or you can delete all items matching a query like so:
Food.objects(type="snacks").delete()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With