Below is my firestore collection structure
My vue method to get data
fetchResults(){
db.collection(\'data\').onSnapshot((querySnapShot)=>{
Instead of calculating the data with an aggregate query, the data should be saved in the document itself using client side logic to update the aggregate data each time the document is changed or use cloud functions.
See this post from Google blog.
https://firebase.google.com/docs/firestore/solutions/aggregation
You can do using
fetchResults(){
db.collection('data')
.orderBy("id", "asc")
.onSnapshot((querySnapShot)=>{
// Do something
})
}
More information visit https://firebase.google.com/docs/firestore/query-data/order-limit-data and you can also apply filter using click on click on filter icon
As a NoSQL type database, Cloud Firestore doesn't offer any aggregation queries such as grouping, sum, max, etc. You have to perform these operations in your client code. For your case, this means you will have to query for all the documents in the collection, then group them by whatever fields you want. Alternatively, you can maintain a separate collection of pre-grouped documents to satisfy your query. (Duplicating data like this is common in NoSQL type databases.)