In example1, I have a structure where there are collections followed by documents in a sequence like collection - doc - collection - doc - collection.
Conversely, in example2, there is just a single collection mentioned.
In example1's structure, I am able to import all document lists from the last collection. However, in example2's structure, I'm unable to retrieve document lists from the collection.
How can I access the top-level collection within the document lists?
Below is the code implementation:
// This is example1 and it works successfully!!
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 but unfortunately, it doesn't work properly.
dbService
.collection("users")
.onSnapshot((snapshot) => {
snapshot.docs.map((doc, index) => {
videoList.push(doc.data());
console.log(doc.data());
});
});
Example2 returns an empty array. Any ideas on why this might be happening?