def post(self):
if db.users.find({"email": email}).count() != 0:
abort(400, message="email is alread used.")
DeprecationWarning: count is deprecated. Use Collection.count_documents instead.
我正在用Python Flask和PyMongo包制作身份验证服务器.每次调用post()
方法时,都会显示上述弃用警告消息.
def post(self):
if db.users.find({"email": email}).count_documents() != 0:
abort(400, message="email is alread used.")
然而,如果我将count()
改为count_documents()
,就会出现以下错误消息.
AttributeError: 'Cursor' object has no attribute 'count_documents'
在调用find()
后,如何正确调用count_documents()
?