I want to get all the documents from a collection, and then with them, get their id. Here how my collections is user collection It's only one collections with multiple documents. I try this but it doesn't work :
let userRef = admin.firestore().collection('users');
return userRef.get().then(querySnapshot => {
let docs = querySnapshot.docs;
for (let doc of docs) {
console.log(doc.id);
}
return true;
});
UPDATE
What i was really trying to do, was to get all the documents id of a parent collections, so that i can use them to iterate in each of these documents which contain a subcollection.
So when i do the same thing who worked for the user collection up here, in this case with a parent collection which have documents id which contain a subcollection, it doesn't work. It's like my collection have no documents in it.
let savedRef = await admin.firestore().collection('saved');
return savedRef.get().then(querySnapshot => {
console.log(querySnapshot);
let docs = querySnapshot.docs;
for (let doc of docs) {
console.log(doc.id);
}
return true;
});
saved collection which contain documents with a subcollection
Do you have any idea why ? Thank you,