title: Aggregation on FireStore/CloudDatastore. Use Cloud Functions onCreate/Update?
body: <p>I want to create an expense tracker and one of the things I want to find out is how much did I spend in each month per category. </p>
  
  <p>How should I do this in FireStore/DataStore? </p>
  
  <ol>
  <li>Pull down required data and do aggregation locally? Seems very slow?</li>
  <li>Perform aggregation everytime a transaction is created/updated and save it in a table? But this may result in many invocations of the functions, which may be costly? </li>
  </ol>
  
  <p>Is there a better way? Seems like 2 is currently the best option? But I wonder if theres anyway I can reduce costs? </p>
  
  <p>I note that I may not need the aggregated data to be realtime, so is there a way to debounce the cloud function execution? Since I note that at times, I will batch insert a bunch of transactions. Wonder if theres a way to disable functions for certain queries and manually call them after the batch has finished for example? </p>