我想和摩托的潜水员一起计数,但我得到了这个错误。
AttributeError: 'AsyncIOMotorCursor' object has no attribute 'count'
这是我的代码:
await MOTOR_CURSOR.users.find().count()发布于 2020-03-31 14:16:44
MotorCollection.find()返回AsyncIOMotorCursor,但它没有count方法。相反,您应该调用MotorCollection.count_documents()。
await db.users.count_documents({'x': 1})同样值得注意的是,您所指的MOTOR_CURSOR是MotorDatabase实例,最好将其称为db实例,而不是游标,以避免混淆。
https://stackoverflow.com/questions/60919782
复制相似问题