How can I print the mongodb query I buid with mongoengine? Example:
queryset = Document.objects(**query)
print queryset.to_mongodb_query()
Yes. There is a .query
accessor on the QuerySet. For example:
queryset = Document.objects(field__lte=5)
print queryset._query
Would produce:
{ "field": { "$lte": 5 } }
You can also call .explain()
for descriptive output to the query execution statistics if you wanted that at another log level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With