[英]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.