Database Reference
In-Depth Information
"result" : [
{
"_id" : ObjectId("53213bc8ae5fcad63d0563f3"),
"first" : "M",
"second" : "E",
"count" : 437
}
],
"ok" : 1
}
After filtering commands are applied in the pipeline, group management
commands are applied. The most commonly used command is the $group
operator, which specifies an identifier field and some number of
accumulators. For example, to sum the “count” field for each of the values of
the “first” field, the pipeline would be declared as follows:
> db.aggtest.aggregate([{$group:{_id:"$first",
total:{$sum:"$count"}}}]);
{
"result" : [
{
"_id" : "V",
"total" : 18224
},
{
"_id" : "Y",
"total" : 15299
},
{
"_id" : "D",
"total" : 20929
},
{
"_id" : "I",
"total" : 13257
},
{
"_id" : "N",
Search WWH ::




Custom Search