【发布时间】: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
当您在数据库中的某个位置获取数据时,您还会检索其所有子节点。
但我找不到在文档中返回集合的权利(不进行新查询)
【问题讨论】:
-
你混合了两个东西,这个例子来自 firestore,链接来自 RTDB。两者都是不同类型的数据库
-
哦.. 我想我的文档有误。谢谢!用firestore获取收藏的方法是什么?你碰巧知道吗?
-
你有你的数据结构是什么样子的例子吗?
-
firebase.google.com/docs/firestore/query-data/get-data 阅读他们包含的所有你需要知道的文档
标签: javascript firebase google-cloud-firestore