In this form of the query results of different partial queries are merged and grouped to form a new result. The following query returns a list of all the states, which have more than 10 million inhabitants.
Codeblock |
---|
|
[
{
$group : {
_id : "$state",
totalPop : {
$sum : "$pop"
}
}
},
{
$match : {
totalPop : {
$gte : 10000000
}
}
}
] |
Hinweis |
---|
The queries must be embedded in an array. Will the appropriate brackets forgotten, this leads to an error message. |
Tipp |
---|
A detailed documentation to the Mongo aggregation framework can be found here: http://docs.mongodb.org/manual/core/aggregation-introduction/ |