簡體   English   中英

使用 Firestore 獲取文檔集合

[英]get collection of documents with firestore

我在關注這個例子:

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

當您在數據庫中的某個位置獲取數據時,您還會檢索其所有子節點。

但我找不到在文檔中返回集合的權利(不進行新查詢)

在 Firestore 中,當您檢索數據時,您將檢索文檔中的所有字段。 如果要從另一個文檔或子集合中檢索數據,則需要執行不同的查詢。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM