I\'m looking for a feasible way to get the length of cursor got from MongoDB.
According to the pymongo documentation, a Pymongo cursor, has a count
method:
count(with_limit_and_skip=False)
By default this method returns the total length of the cursor, for example:
cursor.count()
If you call this method with with_limit_and_skip=True
, the returned value takes limit
and skip
queries into account. For example, the following query will return 5 (assuming you have more than 5 documents):
cursor.limit(5).count(True)