diff --git a/mongoengine/pymongo_support.py b/mongoengine/pymongo_support.py index 284efc2f..9cf9e2ae 100644 --- a/mongoengine/pymongo_support.py +++ b/mongoengine/pymongo_support.py @@ -44,7 +44,8 @@ def count_documents( for option, option_value in kwargs.items(): cursor_method = getattr(cursor, option) cursor = cursor_method(option_value) - return cursor.count() + with_limit_and_skip = "skip" in kwargs or "limit" in kwargs + return cursor.count(with_limit_and_skip=with_limit_and_skip) def list_collection_names(db, include_system_collections=False):