title: Angular, Angularfire2, Getting the average of numbers in the database
body: <p>I been trying to figure this one out for days. I feel like its alot more simple than I think. I am using angular and angularfire2 i have a rating system set up and essentially what I am trying to do is query the collection and get the number field in each document, add them together and get the average. All I know how to do however is query the database, and display all my review in the template and how to get the total number of documents in the collection so i have the number to divide by. I can't figure out in my typscript file how to get all those values and add them together to then get and average. </p>
  
  <pre><code>this.reviews = db.collection('dispensaries').doc(this.id).collection('reviews').snapshotChanges().map(actions =&gt; {
    return actions.map(a =&gt; {
      const data = a.payload.doc.data();
      data.id = a.payload.doc.id;
      console.log(data.stars);
      return data;
    });
  });
  
  
  db.collection('dispensaries').doc(this.id).collection('reviews')
    .ref
    .get().then(function(querySnapshot) {
      console.log(querySnapshot.size);
    });
  </code></pre>