Skip to content

Commit

Permalink
DOCS-9742: fix aggregation example
Browse files Browse the repository at this point in the history
  • Loading branch information
steveren committed Jan 9, 2017
1 parent ae67052 commit c43dc20
Showing 1 changed file with 5 additions and 7 deletions.
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) {
);
}
```


0 comments on commit c43dc20

Please sign in to comment.