DM-Aggregates
DM-Aggregates provides a reporting API which offers aggregating functions like
count
, min
, max
, avg
, sum
, and aggregate
.
Setup
Simply require 'dm-aggregates'
somewhere before you connect to your data-store
and you’re ready to go.
Count
You can issue a totaling query with DM-Aggregates in a couple of ways. First, you can build a totaling query off of your Resource:
Secondly, you can call count
off of a pre-build query object.
Your query will become a totaling query without having to retrieve the objects and total on the retrieved array. These two approaches can be combined as well.
Min, Max
Minimum and Maximum values from fields in your data-store can be retrieved by specifying which property you want to retrieve the value from.
Further conditions to your min and max queries are simply supplied after the property.
Sum, Average
Both sum
, and avg
work very similarly to min
and max
.
Aggregate
The aggregate
method will let you combine all of the other aggregating methods
together to retrieve in one call to the data-store. DM-Aggregates adds in a few
extra symbol operators in order to enable this.
This will compile all of the aggregating queries together and return them in an array of arrays.