python - 我怎样才能从 mongodb 中获取所有具有相同值的数据?

标签 python mongodb fastapi

在我的数据库中,有两家同名的公司。

[
  {
    "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 公司的信息?

最佳答案

关于python - 我怎样才能从 mongodb 中获取所有具有相同值的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71154237/

相关文章:

Python 请求包 : Handling xml response

python - 将括号分隔的字符串拆分为字典

reactjs - 将文件从(快速)API 上传到 Azure Blob 存储

python - 包裹时如何防止seaborn FacetGrid重叠

python - 首次保存时从用户模型获取 OneToOneField 数据

MongoDB不区分大小写索引 "starts with"性能问题

mongodb - 计算符合给定条件的子文档

Java MongoDB异常: can't authenticate twice on the same database

python - 使用 Fast API python web 框架进行行为驱动开发 (BDD) 测试

python - FastAPI + pytest 无法清理 Django ORM