Drop all collections in Mongoengine

I searched the api, but I can not find anything related to deleting the database, without reprocessing through the collection manually.

Is there an easier way to call db.dropDatabase() via mongoengine? This is not a big problem for iteration, you just need an easier way.

+8
python mongodb mongoengine
source share
1 answer

How to do it?

 from mongoengine import connect db = connect('test') db.drop_database('test') 

Alternatively, you can get the connection object from the _get_db() method:

 from mongoengine import connect from mongoengine.connection import _get_db connect('test') db = _get_db() db.connection.drop_database('test') 
+15
source share

All Articles