- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试获取子集合中的文档,该子集合是使用 .where 函数找到的文档的一部分
例子:
我想从字段级别 == 1 的文档中获取 SubColl 1
下的所有文档
我正在尝试这样做:
db.collection("RootColl").where("field", "==", "1").collection("SubColl 1").get()
但是这样做我得到了错误
Uncaught TypeError: db.collection(...).where(...).collection is not a function
编辑 1:按照 Frank van Puffelen 的建议,我得到了同样的错误,“集合”不是函数
最佳答案
子集合位于特定文档下。您共享的查询现在指向 多个文档。您需要执行查询以确定它指向哪些文档,然后遍历结果,并获取每个文档的子集合。
在代码中:
var query = db.collection("RootColl").where("field", "==", "1");
query.get().then((querySnapshot) => {
querySnapshot.forEach((document) => {
document.ref.collection("SubColl 1").get().then((querySnapshot) => {
...
});
});
});
关于javascript - Firestore : Get subcollection of document found with where,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47634907/
我正在使用 Cloud Firestore 并制作评论部分以便用户可以发表评论。 我在下面找到的一些代码: export function saveComment(comment, id, uid)
我正在使用 Firestore 作为 Flutter 项目的后端,数据库嵌套在文档下有子集合。结构如下: 我有从 Root 集合中找到的数据,我试图从那里获取子集合,但我不知道如何获取。 应该有可用的
我正在尝试获取子集合中的文档,该子集合是使用 .where 函数找到的文档的一部分 例子: 根目录/ 文件 A/ 子集 1 文档 1 文档 2 文档 3 子库 2 文档 文件 A/ 子集 1 文档 1
是否可以使用 iOS SDK 在文档中创建子集合?我在 API 上找不到任何合适的方法和 documentation不提供任何指南。 最佳答案 作为一般规则,您不会明确地“创建”集合。相反,您创建文档
在 Flutter Firestore 中,我这样做是为了添加一个文档: Firestore.instance .collection('groups').add({'name': 'Grou
我如何才能只阅读当前用户的评论?对于“我自己的评论”页面。我的代码已运行,但如果(其中字段:currentuid)不存在则不打印(“无数据”)。只打印 ("documents.data()")
我有以下子集合结构: /projects/{projectId}/documents/{documentId} 其中每个文档都有一个用于检查每个文档的安全规则的访问映射: { title: "A
我有以下子集合结构: /projects/{projectId}/documents/{documentId} 其中每个文档都有一个用于检查每个文档的安全规则的访问映射: { title: "A
我目前有一些访问我的 firestore 数据库的基本规则。规则详述如下。谁能帮我理解为什么第二段代码会导致权限错误?我正在尝试将图像添加到尚不存在的子集合中。谢谢 rules_version = '
我正在编写一个管理各种联盟的 react 小程序。 我遇到的问题是如何允许正确用户访问(读取、写入)联赛的比赛日。比赛日被命名为“matchday-1”、“matchday-2”等,并且是文档(比赛)
我有一个商店集合,每个商店都有一个项目的子集合。项目文档有一个属性 isAvailable,它是一个 bool 值。 然后,我需要将商品放入用户的购物车。重要的是要观察商品 isAvailable 值
我是一名优秀的程序员,十分优秀!