Added tailable and await_data options to find()

This commit is contained in:
2014-07-04 13:16:06 +03:00
parent b7504643fc
commit ec2fef6b4b

View File

@@ -90,7 +90,8 @@ class Collection(object):
return {} return {}
@coroutine @coroutine
def find(self, spec=None, skip=0, limit=0, fields=None, filter=None, _proto=None): def find(self, spec=None, skip=0, limit=0, fields=None, filter=None, _proto=None,
tailable=False, await_data=False):
if spec is None: if spec is None:
spec = SON() spec = SON()
@@ -121,7 +122,8 @@ class Collection(object):
proto = self._database._protocol proto = self._database._protocol
else: else:
proto = _proto proto = _proto
return (yield from proto.OP_QUERY(str(self), spec, skip, limit, fields)) return (yield from proto.OP_QUERY(str(self), spec, skip, limit, fields,
tailable, await_data))
@coroutine @coroutine
def find_one(self, spec=None, fields=None, _proto=None): def find_one(self, spec=None, fields=None, _proto=None):
@@ -193,7 +195,7 @@ class Collection(object):
if callit is True: if callit is True:
return None return None
return result return result
@coroutine @coroutine
@@ -281,14 +283,14 @@ class Collection(object):
if "bucket_size" in kwargs: if "bucket_size" in kwargs:
kwargs["bucketSize"] = kwargs.pop("bucket_size") kwargs["bucketSize"] = kwargs.pop("bucket_size")
index.update(kwargs) index.update(kwargs)
yield from self._database.system.indexes.insert(index, safe=True) yield from self._database.system.indexes.insert(index, safe=True)
return name return name
@coroutine @coroutine
def ensure_index(self, sort_fields, **kwargs): def ensure_index(self, sort_fields, **kwargs):
# ensure_index is an alias of create_index since we are not # ensure_index is an alias of create_index since we are not
# keep an index cache same way pymongo does # keep an index cache same way pymongo does
return (yield from self.create_index(sort_fields, **kwargs)) return (yield from self.create_index(sort_fields, **kwargs))
@@ -380,4 +382,4 @@ class Collection(object):
return None return None
else: else:
raise ValueError("Unexpected Error: %s" % (result,)) raise ValueError("Unexpected Error: %s" % (result,))
return result.get('value') return result.get('value')