May 21, 2024


Ceaselessly, Firestore prospects have to calculate a sum or common on a specific subject throughout their paperwork. With right now’s launch of SUM() and AVG() aggregation capabilities, Firestore prospects can simply calculate aggregations like the full revenue for merchandise gross sales utilizing SUM(), or the typical distance traveled by all fleet automobiles utilizing AVG().


To make use of this function, merely specify the aggregation perform and the sphere title. Firestore computes the SUM() and AVG() outcomes straight by way of index scans. This makes it environment friendly, but additionally signifies that a subject should be listed to calculate an aggregation.

For instance, if we now have a set known as “tripsCollection”, to be able to get the full distance by automobiles which might be of kind “bike”, you would run the beneath question:


Source link