Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sakulstra/meteor-aggregate
Proper MongoDB aggregations support for Meteor
https://github.com/sakulstra/meteor-aggregate
Last synced: about 2 months ago
JSON representation
Proper MongoDB aggregations support for Meteor
- Host: GitHub
- URL: https://github.com/sakulstra/meteor-aggregate
- Owner: sakulstra
- License: mit
- Fork: true (meteorhacks/meteor-aggregate)
- Created: 2018-05-06T11:03:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-15T18:04:00.000Z (almost 3 years ago)
- Last Synced: 2024-08-04T01:03:14.244Z (5 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 40
- Watchers: 4
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-meteor - sakulstra:aggregate - Add proper aggregation support for Meteor. (Collections)
README
[![](https://api.travis-ci.org/meteorhacks/meteor-aggregate.svg)](https://travis-ci.org/meteorhacks/meteor-aggregate)
# maintained fork of meteorhacks:aggregate
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
## Usage
Add to your app with
```
meteor add sakulstra:aggregate
```Then simply use `.aggregate` function like below.
```js
var metrics = new Mongo.Collection('metrics');
var pipeline = [
{$group: {_id: null, resTime: {$sum: "$resTime"}}}
];
var result = metrics.aggregate(pipeline);
```### Using Options
~~~js
var result = new Mongo.Collection('metrics');
var metrics = new Mongo.Collection('metrics');
var pipeline = [
{$group: {_id: null, resTime: {$sum: "$resTime"}}}
];
var result = metrics.aggregate(pipeline, {explain: true});
console.log("Explain Report:", JSON.stringify(result[0]), null, 2);
~~~## Why?
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)
## What the fork?!
meteorhacks/meteor-aggregate seems pretty unmaintained, so let's maintain a fork!
Meteor 1.7 and it's upgrade to mongodriver v3 introduced some breaking changes which will break meteorhacks:meteor-aggregate.## Breaking changes
- `meteorhacks:[email protected]` is no longer a dependency. If you're using meteor <= 1.0.4 you have to add it manually.