0

I'm looking a right way to iterate in firestore docs;

        this.globalCounters = firebase.firestore().collection('AnswersCounters').doc('Questions')

enter image description here

I found a way to do this with Object.keys() but I don't think this way is the right one.

        this.unsubscribe_globalCounters = this.globalCounters.onSnapshot(this.showAnswers) 


 showAnswers(querySnapshot){

    let snapshotData = querySnapshot.data();
    let answersCounters =[]
    Object.keys(snapshotData).map((i)=>{

        answersCounters.push({key:i,count:snapshotData[i]})

        })
}
Frank van Puffelen
  • 499,950
  • 69
  • 739
  • 734
Manspof
  • 2,005
  • 22
  • 70
  • 159

0 Answers0