|
http://docs.mongodb.org/manual/reference/method/db.collection.aggregate/
The example output includes the keys "ok" and "result".
This no longer holds true as of 2.5.3 as aggregate() now returns a cursor by default:
> db.articles.aggregate(
|
... { $project : {
|
... author : 1,
|
... tags : 1,
|
... }
|
... },
|
... { $unwind : "$tags" },
|
... { $group : {
|
... _id : { tags : "$tags" },
|
... authors : { $addToSet : "$author" }
|
... }
|
... }
|
... )
|
{ "_id" : { "tags" : "sport" }, "authors" : [ "bob" ] }
|
{ "_id" : { "tags" : "good" }, "authors" : [ "bob" ] }
|
{ "_id" : { "tags" : "fun" }, "authors" : [ "bob" ] }
|
>
|
|