I want to get count with Motor's diver but I got this error.
AttributeError: 'AsyncIOMotorCursor' object has no attribute 'count'
This is my code:
await MOTOR_CURSOR.users.find().count()
I want to get count with Motor's diver but I got this error.
AttributeError: 'AsyncIOMotorCursor' object has no attribute 'count'
This is my code:
await MOTOR_CURSOR.users.find().count()
Copyright © 2021 Jogjafile Inc.
MotorCollection.find() returns AsyncIOMotorCursor and it does not have
countmethod. Instead, you should call MotorCollection.count_documents() instead.Also worth noting that what you're referring to as
MOTOR_CURSORis MotorDatabase instance, it would preferable to call it a db instance instead of a cursor to avoid confusion.