Database Reference
In-Depth Information
{ $limit : 5 }
]
This returns the following result:
{
"result" : [
{
"_id" : {
"color" : "white",
"transport" : "boat"
},
"count" : 9
},
{
"_id" : {
"color" : "black",
"transport" : "motorbike"
},
"count" : 9
},
{
"_id" : {
"color" : "maroon",
"transport" : "train"
},
"count" : 9
},
{
"_id" : {
"color" : "blue",
"transport" : "autombile"
},
"count" : 9
},
{
"_id" : {
"color" : "green",
"transport" : "autombile"
},
"count" : 9
}
],
"ok" : 1
}
You will notice that the results returned are almost completely different from previous examples. This is because
the order in which the documents were created has now changed. As such, when we run this query we limit the
output, removing the original documents that had been our output earlier. You will also see that our counts are half
the values of the earlier results. This is because we have cut our potential set of data to aggregate upon to about half
the size it was before. If we want to have consistency among our return results, we need to invoke another pipeline
operator, $sort .
Search WWH ::




Custom Search