def find(self, *args, **kwargs):
"""Create a :class:`MongoMotorAgnosticCursor`. Same parameters as for
PyMongo's :meth:`~pymongo.collection.Collection.find`.
Note that ``find`` does not take a `callback` parameter, nor does
it return a Future, because ``find`` merely creates a
:class:`MongoMotorAgnosticCursor` without performing any operations
on the server.
``MongoMotorAgnosticCursor`` methods such as
:meth:`~MongoMotorAgnosticCursor.to_list` or
:meth:`~MongoMotorAgnosticCursor.count` perform actual operations.
"""
if 'callback' in kwargs:
raise pymongo.errors.InvalidOperation(
"Pass a callback to each, to_list, or count, not to find.")
cursor = self.delegate.find(*args, **kwargs)
cursor_class = create_class_with_framework(
MongoMotorAgnosticCursor, self._framework, self.__module__)
return cursor_class(cursor, self)
评论列表
文章目录