【问题标题】:get collection of documents with firestore使用 firestore 获取文档集合
【发布时间】:2020-08-01 02:55:58
【问题描述】:

我正在关注这个例子:

var docRef = db.collection("cities").doc("SF");

docRef.get().then(function(doc) {
    if (doc.exists) {
        console.log("Document data:", doc.data());
        // this is not working
        const people = doc.collection("people");
    } else {
        // doc.data() will be undefined in this case
        console.log("No such document!");
    }
}).catch(function(error) {
    console.log("Error getting document:", error);
});

我想返回旧金山市内的一组人。

根据https://firebase.google.com/docs/database/web/structure-data

当您在数据库中的某个位置获取数据时,您还会检索其所有子节点。

但我找不到在文档中返回集合的权利(不进行新查询)

【问题讨论】:

标签: javascript firebase google-cloud-firestore


【解决方案1】:

在 Firestore 中检索数据时,会检索文档中的所有字段。如果要从另一个文档或子集合中检索数据,则需要执行不同的查询。

【讨论】:

    猜你喜欢
    • 2018-04-09
    • 2019-10-06
    • 2018-04-04
    • 2019-11-13
    • 2021-03-27
    • 2019-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多