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
  • 565,676
  • 79
  • 828
  • 807
Manspof
  • 598
  • 26
  • 81
  • 173

0 Answers0