mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
Add MongoDB aggregation to Collections
It would be great to allow mongodb aggregation. I am personally using geoNear for example.
This commit is contained in:
parent
299d83df98
commit
90c3e8d2cd
1 changed files with 12 additions and 1 deletions
|
@ -6,6 +6,7 @@ import { runCallbacks } from './callbacks.js';
|
||||||
import { getSetting, registerSetting } from './settings.js';
|
import { getSetting, registerSetting } from './settings.js';
|
||||||
import { registerFragment, getDefaultFragmentText } from './fragments.js';
|
import { registerFragment, getDefaultFragmentText } from './fragments.js';
|
||||||
import escapeStringRegexp from 'escape-string-regexp';
|
import escapeStringRegexp from 'escape-string-regexp';
|
||||||
|
wrapAsync = (Meteor.wrapAsync)? Meteor.wrapAsync : Meteor._wrapAsync;
|
||||||
// import { debug } from './debug.js';
|
// import { debug } from './debug.js';
|
||||||
|
|
||||||
registerSetting('maxDocumentsPerRequest', 1000, 'Maximum documents per request');
|
registerSetting('maxDocumentsPerRequest', 1000, 'Maximum documents per request');
|
||||||
|
@ -79,6 +80,16 @@ Mongo.Collection.prototype.addView = function (viewName, view) {
|
||||||
this.views[viewName] = view;
|
this.views[viewName] = view;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Allow mongodb aggregation
|
||||||
|
* @param {Array} pipelines mongodb pipeline
|
||||||
|
* @param {Object} options mongodb option object
|
||||||
|
*/
|
||||||
|
Mongo.Collection.prototype.aggregate = function (pipelines, options) {
|
||||||
|
var coll = this.rawCollection();
|
||||||
|
return wrapAsync(coll.aggregate.bind(coll))(pipelines, options);
|
||||||
|
};
|
||||||
|
|
||||||
// see https://github.com/dburles/meteor-collection-helpers/blob/master/collection-helpers.js
|
// see https://github.com/dburles/meteor-collection-helpers/blob/master/collection-helpers.js
|
||||||
Mongo.Collection.prototype.helpers = function(helpers) {
|
Mongo.Collection.prototype.helpers = function(helpers) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
Loading…
Add table
Reference in a new issue