I'm trying to iterate over the nodes of a given collection in Firestore, but it does not seems to work. I'm new on Javascript so the data structure is not well clear to me.
The following code was my attempt. I've failed because it appears an errors which tells me that the forEach()
function is not defined. However, it does not make sense to me. This documentation shows that the return of the get function is Promise<QuerySnapshot>
. On the sequence, this doc shows the method of the QuerySnapshot objects and it appears the forEach
method.
var myarray = firebase.firestore().collection('cards').get();
myarray.forEach( k => {
console.log(k)
});
I came here seeking for help. Could someone explains me why the forEach method does not exists for the given object and how can I iterate over the child nodes on the cards
collection, so I could check their attributes?