Question

Is it possible to iterate over collections in mongoengine. I have collections named log_XXX and I'd like to find all of them.

Was it helpful?

Solution

Mongoengine is built on top of PyMongo, so you can do everything you can do in PyMongo.

For example,

class Example(Document):
    pass

db = Example._get_db()
for collection_name in db.collection_names():
    print collection_name
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top