Firestore Group by field

前端 未结 3 1490
甜味超标
甜味超标 2021-01-25 23:19

Below is my firestore collection structure

My vue method to get data

fetchResults(){
  db.collection(\'data\').onSnapshot((querySnapShot)=>{
         


        
3条回答
  •  盖世英雄少女心
    2021-01-26 00:13

    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.)

提交回复
热议问题