【发布时间】:2021-08-09 21:48:11
【问题描述】:
def get_registered_user():
users = collection_users.find({name:'john'}, {'regDate': regDate}).count()
pprint.pprint("users:" + str(users))
在 mongoDB python 中使用 count() 方法时,我收到警告为“DeprecationWarning:count 已弃用。请改用 Collection.count_documents。”
Collection.count_documents() 只接受一个查询。如何同时通过以上两个查询?请帮忙。
【问题讨论】:
-
您不能同时将两个查询传递给任何 mongodb 操作,因为这样做没有意义。您现有的代码可能已损坏。
-
@D.SM 有没有办法检查以上两个条件来计算最终结果
-
在同一个字典中传递它们。