How do I iterate over collections in a database in mongoengine? [closed]
-
20-12-2019 - |
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.
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