How to delete document from MongoDB using Mongoengine?

26,319

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()
Share:
26,319
ehsan shirzadi
Author by

ehsan shirzadi

I'm Ehsan. Currently I'm a backend developer and also DevOps engineer of an international company. My personal interests are: Development of big project in scrum framework Taking advantage of new technologies Distributed systems Big data management Real time processing If you want to develop your projects, you can count on me, please contact me: [email protected] thank you.

Updated on November 20, 2020

Comments

  • ehsan shirzadi
    ehsan shirzadi over 3 years

    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?