Open rubenheymans opened 8 months ago
This issue does not seem to follow the issue template. Make sure you provide all the required information.
import { average, collection, getAggregateFromServer, getCountFromServer, sum } from '@angular/fire/firestore';
const usersCollection = collection(this.firestore, 'users'); // collection of users
const count = await getCountFromServer(usersCollection); // our query to count number of users (number of documents in a collection)
console.log("count",count.data().count);
const sumQuery = await getAggregateFromServer(usersCollection, {
totalLikes: sum('likes'),
totalSubscriptions: average('subscriptions')
}); // query to sum total likes and average total subscriptions
console.log("sumQuery",sumQuery.data());
Please, when you are upto a discussion go and talk in the discussions channel. Raising an issue for a doubt or exemplary solution isn't a really great idea. Issues are there to solve problems and bugs for the library itself.
Good
how can we use count, sum and average with angularfire? https://firebase.google.com/docs/firestore/query-data/aggregation-queries