如何计算集群中有多少文档?

2024-06-17 15:44:33 发布

您现在位置:Python中文网/ 问答频道 /正文

(discord.py,mongodb)

我试图找到这个特定集群中有多少文档,我尝试使用中的db.collection.count()

db = cluster["databaseTest"]
collection = db["timers"]

timer_info = {"Length": atime, "Created at": ctx.message.created_at, "Custom_thing": "hi"}
collection.insert_one(timer_info)

timer_amount = db.collection.count("Custom_thing":"hi")

我没有收到任何错误,但它一直说timer\u amount=0,即使其中还有其他文档