Created
August 22, 2014 21:08
-
-
Save misutowolf/58c83cfd5a299e1ca4c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| classCount: function() { | |
| // Attempt aggregation of the books table to count by class, maybe. | |
| var db = MongoInternals.defaultRemoteCollectionDriver().mongo.db; | |
| var col = db.collection("books"); | |
| var aggregateSync = Meteor._wrapAsync(col.aggregate.bind(col)); | |
| var pipeline = [ | |
| {$group: {_id: "$class", count: {$sum: 1}}}, | |
| {$sort: {_id: 1}} | |
| ]; | |
| var theAnswer = aggregateSync(pipeline); | |
| return theAnswer; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment