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?
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.delete() // Delete it!
Or you can delete all items matching a query like so:
Food.objects(type="snacks").delete()
lunch = Food.objects.get() if you expect one and only one document to match the query (typically request by ID).U can use the mongoshell and issue the following command:
db.collection.remove({your condition on documents you want to remove})
for example: From food collection you want to remove all the food which has type snacks. then you can issue the following command:
db.food.remove( { type : "snacks" } )
fsync: Truei think that force write on primary ( journaled )