Navigation
This version of the documentation is archived and no longer supported.

db.collection.aggregate()

db.collection.aggregate(pipeline)

New in version 2.2.

Always call the db.collection.aggregate() method on a collection object.

Arguments:
  • pipeline – Specifies a sequence of data aggregation processes. See the aggregation reference for documentation of these operators.

Consider the following example from the aggregation documentation.

db.article.aggregate(
  { $project : {
     author : 1,
     tags : 1,
  } },
  { $unwind : "$tags" },
  { $group : {
     _id : { tags : 1 },
     authors : { $addToSet : "$author" }
  } }
);