[Chartjs]-Convert FirestoreCollection into an array?

26👍

Calling this.updatesCollection.get() will asynchronously return a querySnapshot object.

A querySnapshot has a docs property which is an array containing zero or more documentSnapshot objects. The data in these can be extracted with the .data() method.

The code for producing your array could look like this:

let chartData = this.updates.collection.get()
  .then(querySnapshot => {
    chartData = querySnapshot.docs.map(doc => doc.data())
  })

Leave a comment