From c48f5e9aff05877be5f88ed26603f9f865cb71aa Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenok Date: Thu, 9 Feb 2017 17:50:11 +0100 Subject: [PATCH 1/2] added aggregateAsync for asynchronous aggregation For cursors support http://mongodb.github.io/node-mongodb-native/2.0/tutorials/streams/ --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index 62bd4ed..a58acd8 100644 --- a/index.js +++ b/index.js @@ -10,3 +10,15 @@ Mongo.Collection.prototype.aggregate = function(pipelines, options) { } return wrapAsync(coll.aggregate.bind(coll))(pipelines, options); } + +Mongo.Collection.prototype.aggregateAsync = function() { + var collection; + if (this.rawCollection) { + // >= Meteor 1.0.4 + collection = this.rawCollection(); + } else { + // < Meteor 1.0.4 + collection = this._getCollection(); + } + return collection.aggregate.call(collection, arguments); +} From 4e9946b9c225c4999422be4994735c978938f56a Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenok Date: Thu, 9 Feb 2017 18:00:44 +0100 Subject: [PATCH 2/2] proper arguments passing --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index a58acd8..a862a61 100644 --- a/index.js +++ b/index.js @@ -20,5 +20,5 @@ Mongo.Collection.prototype.aggregateAsync = function() { // < Meteor 1.0.4 collection = this._getCollection(); } - return collection.aggregate.call(collection, arguments); + return collection.aggregate.call(collection, Array.prototype.slice.call(arguments)); }