mongoengine
mongoengine copied to clipboard
Use estimated_documents_count OR documents_count based on query
Since .count was deprecated, MongoEngine was switched to the Collection.count_documents method exclusively. This caused major issue for people for simple cases where estimated_documents_count could be used.
This PR adds a bit of logic behind the .count() method to make use of estimated_count_documents whenever it is safe to do so.
This is a fix for #2470
@bagerard Is this safe to get merged? Seems like a sensible improvement