June 2014
Intermediate to advanced
696 pages
38h 52m
English
MongoDB’s aggregation framework is extremely powerful in that it allows you to pipe the results of one aggregation operator into another multiple times. This data set shows an example:
{o_id:"A", value:50, type:"X"}{o_id:"A", value:75, type:"X"}{o_id:"B", value:80, type:"X"}{o_id:"C", value:45, type:"Y"}
The following aggregation operator set would pipeline the results of the $match into the $group operator and then return the grouped set in the results parameter of the callback function. Notice that when referencing the values of fields in documents, the fieldname is prefixed by a dollar sign—for example, $o_id and $value. This syntax tells the aggregate framework to treat it ...
Read now
Unlock full access