【问题标题】:How to query documents containing an array of objects in Firestore with python如何使用python在Firestore中查询包含对象数组的文档
【发布时间】:2020-12-05 07:39:20
【问题描述】:

我有一个集合 users,其中包含一个对象数组字段: {"status":"active", "children": [{"name": "jack", "id": 1234}]}

我正在尝试搜索此集合并找到 children.id 等于 1234 的用户。

我试过这个:

db.collection('users').where('children', 'array_contains', {'id': 1234}).get()

还有这个:

db.collection('users').where('children.id', '==', 1234).get() 但没有用。

如何在 Firestore 上进行此类查询?

【问题讨论】:

    标签: python firebase google-cloud-firestore


    【解决方案1】:

    很遗憾,您不能以这种方式查询,而且这个问题已经在here 中讨论过。您需要修改数据结构。

    【讨论】:

      猜你喜欢
      • 2019-02-20
      • 1970-01-01
      • 2018-03-23
      • 2021-09-10
      • 1970-01-01
      • 2019-01-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多