【发布时间】:2019-11-28 14:16:11
【问题描述】:
我正在使用find 从数据库中提取数据,并使用count 检查是否存在任何内容(或者是否为空)。
count is deprecated. Use Collection.count_documents instead. 对我大喊大叫,但是当我改变它时,它在说
'Cursor' object has no attribute 'count_documents'。我尝试将collection 添加到db.find(),但仍然没有。
def stuff(x):
return db['stuffs'].find({"stuff": x})
def check_for_stuff(x):
things = stuff(x)
if not things.count():
return None
【问题讨论】:
-
发布你想要做的事情。
-
贴出你目前使用过的代码
标签: python mongodb collections