Skip to content

DOCS-9742: fix aggregation example #1462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions docs/reference/content/tutorials/aggregation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ and operators, see the
[manual:](https://docs.mongodb.com/manual/core/aggregation-pipeline/)

The following example uses the aggregation pipeline on the
``restaurants`` sample dataset to find
a list of the total number of 5-star restaurants, grouped by restaurant
category.
[restaurant](https://docs.mongodb.org/getting-started/node/import-data/)
sample dataset to find a list of restaurants located in the Bronx,
grouped by restaurant category.

```js
var MongoClient = require('mongodb').MongoClient
Expand All @@ -48,9 +48,9 @@ MongoClient.connect(url, function(err, db) {
var simplePipeline = function(db, callback) {
var collection = db.collection( 'restaurants' );
collection.aggregate(
[ { '$match': { "stars": 5 } },
[ { '$match': { "borough": "Bronx" } },
{ '$unwind': '$categories'},
{ '$group': { '_id': "$categories", 'fiveStars': { '$sum': 1 } } }
{ '$group': { '_id': "$categories", 'Bronx restaurants': { '$sum': 1 } } }
],
function(err, results) {
assert.equal(err, null);
Expand Down Expand Up @@ -179,5 +179,3 @@ var simpleDistinct = function(db, callback) {
);
}
```