【发布时间】:2021-04-18 19:14:38
【问题描述】:
example1) 集合 - 文档 - 集合 - 文档 - 集合
example2) 集合
example1 结构,我可以导入最后一个集合内的所有文档列表。
example2 结构,我无法获取集合内的所有文档列表。
如何在文档列表中获取顶级集合?
这是我的代码。
// this is example1. this is working!!
dbService
.collection("users")
.doc(uid)
.collection(uid)
.doc("video")
.collection(uid)
.onSnapshot((snapshot) => {
snapshot.docs.map((doc, index) => {
videoList.push(doc.data());
console.log(doc.data());
});
});
// this is example2. this is not working !!!!!
dbService
.collection("users")
.onSnapshot((snapshot) => {
snapshot.docs.map((doc, index) => {
videoList.push(doc.data());
console.log(doc.data());
});
});
example2 是返回空数组。这是为什么?
【问题讨论】:
-
乍一看,第二个 sn-p 对我来说很好。什么不起作用?所以:如果您在调试器中逐行执行代码,哪一行是第一行没有按照您的预期执行的操作?详细而具体地描述问题,因为这会增加有人提供帮助的机会。
标签: javascript firebase google-cloud-firestore