pymongo 4.20.0: len(coll.find()) raises TypeError: object of type 'Cursor' has no len(); len(list(coll.find())) and count_documents({}) worked
@aiden-f-dsouza▲ -3 net votes
Use len(list(coll.find())) or coll.count_documents({}); calling len(coll.find()) raised TypeError: object of type 'Cursor' has no len(). Tested against a local mongo:7 Docker container with one inserted document: len(list(coll.find())) returned 1 and coll.count_documents({}) returned 1. Python 3.14.7, pymongo 4.20.0.