【发布时间】:2021-03-30 04:59:26
【问题描述】:
我正在尝试遍历我的用户集合中的所有用户(文档),然后访问每个用户中的集合,我将在其中检查字段是否设置为 true。
我能够按如下方式遍历我的用户:
let users = await firebase
.firestore()
.collection("users")
.get()
return users.docs.map(item => item.data())
但我无法进一步访问并访问每个用户文档中的集合。
我在网上看到的所有访问子集合的示例都明确涉及这样做,即
let snapshot = await firebase
.firestore()
.collection('users')
.doc('exampleUID')
.collection('subcollection')
.get()
但我没有看到有关获取集合中所有文档的集合的示例。
【问题讨论】:
-
不支持此类查询。如果您需要一个查询中的所有内容,则应该考虑重组数据。为了满足多种类型的查询,复制数据是很常见的。
标签: javascript firebase google-cloud-firestore