Name: meteor-aggregate
Owner: meteorhacks
Description: Proper MongoDB aggregations support for Meteor
Created: 2014-10-25 23:51:46.0
Updated: 2018-03-07 02:54:53.0
Pushed: 2017-10-27 13:38:51.0
Homepage: null
Size: 202
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A simple package to add proper aggregation support for Meteor. This package exposes .aggregate
method on Mongo.Collection
instances.
this only works on server side and there is no oberserving support or reactivity built in
Add to your app with
or add meteorhacks:aggregate
Then simply use .aggregate
function like below.
metrics = new Mongo.Collection('metrics');
pipeline = [
group: {_id: null, resTime: {$sum: "$resTime"}}}
result = metrics.aggregate(pipeline);
result = new Mongo.Collection('metrics');
metrics = new Mongo.Collection('metrics');
pipeline = [
group: {_id: null, resTime: {$sum: "$resTime"}}}
result = metrics.aggregate(pipeline, {explain: true});
ole.log("Explain Report:", JSON.stringify(result[0]), null, 2);
There are few other aggregation packages out there. All of them written with some complex hacks and there are some easy way to do things. They also don't work with custom Mongo drivers as well.
And this package is short and simple. (~20 LOC)