guileen/node-mongoskin — Issue #31: How to use Aggregation Framework in mongoskin?
Author: fengmk2
Created: 2012-02-03 09:40:12+00:00
State: open

http://www.mongodb.org/display/DOCS/Aggregation+Framework

If I want to run this command, how can I do it?

```
> db.runCommand({aggregate: "posts", pipeline: [
{
// extract the fields we'll need
$project: {
title : 1,
url : 1,
comments : 1
}
},
{
// explode "comments" array into separate documents
$unwind: "$comments"
},
{
// count up votes by author
$group : {
_id : "$comments.author",
popularity : {$sum : "$comments.votes"}
}
},
{
// sort by the new popular field
$sort: {
"popularity" : -1
}
}]})
```