How to get the length of a cursor from mongodb using python?

后端 未结 6 1478
南笙
南笙 2021-02-19 01:49

I\'m looking for a feasible way to get the length of cursor got from MongoDB.

6条回答
  •  梦谈多话
    2021-02-19 02:36

    It's actually as simple as

    len(list(cursor))
    

    Note that it will however consume the cursor.

提交回复
热议问题