在我的数据库中,有两家同名的公司。
[
{
"name": "samsung",
"store_code": "34d"
},
{
"name": "lg",
"store_code": "333"
},
{
"name": "lg",
"store_code": "3511"
}
]
像这样..
我的问题是,我只是让我的 python 函数通过名称获取商店信息。
看起来像这样..
async def fetch_store_by_name(store_name):
document = collection.find_one({"name":store_name})
return document
而且我只能得到第一家lg公司的信息。 如何从我的 mongodb 中获取 lg 公司的信息?
最佳答案
使用 find
而不是 find_one
。
关于python - 我怎样才能从 mongodb 中获取所有具有相同值的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71154237/