QuerySet.first now uses existing cursor
This commit is contained in:
parent
f98e9bd732
commit
3574198210
1 changed files with 4 additions and 3 deletions
|
|
@ -104,9 +104,10 @@ class QuerySet(object):
|
||||||
def first(self):
|
def first(self):
|
||||||
"""Retrieve the first object matching the query.
|
"""Retrieve the first object matching the query.
|
||||||
"""
|
"""
|
||||||
result = self._collection.find_one(self._query)
|
try:
|
||||||
if result is not None:
|
result = self[0]
|
||||||
result = self._document._from_son(result)
|
except IndexError:
|
||||||
|
result = None
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def with_id(self, object_id):
|
def with_id(self, object_id):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue