From 06433c709c8b9e763eeedf1c580bf1ef10178cfc Mon Sep 17 00:00:00 2001 From: FishSaidNo Date: Thu, 19 Jul 2018 10:46:06 +1000 Subject: [PATCH 1/2] Updated to work with Meteor 1.7 --- aggregate.js | 2 +- mongo-collection-aggregate.js | 7 ------- package.js | 16 ++++++++-------- 3 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 mongo-collection-aggregate.js diff --git a/aggregate.js b/aggregate.js index 12fffd6..0813f3c 100644 --- a/aggregate.js +++ b/aggregate.js @@ -12,7 +12,7 @@ const defaultOptions = ({ ...options }); -export const ReactiveAggregate = function (subscription, collection, pipeline = [], options = {}) { +ReactiveAggregate = function (subscription, collection, pipeline = [], options = {}) { // fill out default options const { observeSelector, observeOptions, delay, lookupCollections, clientCollection diff --git a/mongo-collection-aggregate.js b/mongo-collection-aggregate.js deleted file mode 100644 index 8062b51..0000000 --- a/mongo-collection-aggregate.js +++ /dev/null @@ -1,7 +0,0 @@ -import { Meteor } from 'meteor/meteor'; -import { Mongo } from 'meteor/mongo'; - -Mongo.Collection.prototype.aggregate = function(pipeline, options) { - const collection = this.rawCollection(); - return Meteor.wrapAsync(collection.aggregate.bind(collection))(pipeline, options); -} diff --git a/package.js b/package.js index 26008e1..5583e39 100644 --- a/package.js +++ b/package.js @@ -1,19 +1,19 @@ Package.describe({ - name: "jcbernack:reactive-aggregate", - version: "1.0.0", + name: 'jcbernack:reactive-aggregate', + version: '1.1.0', // Brief, one-line summary of the package. summary: "Reactively publish aggregations.", // URL to the Git repository containing the source code for this package. - git: "https://github.com/JcBernack/meteor-reactive-aggregate", + git: 'https://github.com/JcBernack/meteor-reactive-aggregate', // By default, Meteor will default to using README.md for documentation. // To avoid submitting documentation, set this field to null. - documentation: "README.md" + documentation: 'README.md' }); Package.onUse(function(api) { - api.versionsFrom("1.5"); - api.use(['ecmascript', 'underscore', 'mongo']); + api.versionsFrom('1.5'); + api.use(['ecmascript', 'underscore', 'mongo', 'sakulstra:aggregate@1.4.3'], ['server']); - api.addFiles("./mongo-collection-aggregate.js"); - api.mainModule("./aggregate.js"); + api.export('ReactiveAggregate', 'server'); + api.mainModule('aggregate.js', 'server'); }); From cbe4b1abce9875dbb1ebd0638d4f48e02c400233 Mon Sep 17 00:00:00 2001 From: FishSaidNo Date: Fri, 20 Jul 2018 08:30:58 +1000 Subject: [PATCH 2/2] Export as default export. --- README.md | 2 ++ aggregate.js | 2 +- package.js | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1383a38..2895eb3 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Reactively publish aggregations. This helper can be used to reactively publish the results of an aggregation. ## Usage + import ReactiveAggregate from 'meteor/jcbernack:reactive-aggregate'; + ReactiveAggregate(subscription, collection, pipeline[, options]) - `subscription` should always be `this` in a publication. diff --git a/aggregate.js b/aggregate.js index 0813f3c..cb964c8 100644 --- a/aggregate.js +++ b/aggregate.js @@ -12,7 +12,7 @@ const defaultOptions = ({ ...options }); -ReactiveAggregate = function (subscription, collection, pipeline = [], options = {}) { +export default ReactiveAggregate = function (subscription, collection, pipeline = [], options = {}) { // fill out default options const { observeSelector, observeOptions, delay, lookupCollections, clientCollection diff --git a/package.js b/package.js index 5583e39..6c411e5 100644 --- a/package.js +++ b/package.js @@ -2,7 +2,7 @@ Package.describe({ name: 'jcbernack:reactive-aggregate', version: '1.1.0', // Brief, one-line summary of the package. - summary: "Reactively publish aggregations.", + summary: 'Reactively publish aggregations.', // URL to the Git repository containing the source code for this package. git: 'https://github.com/JcBernack/meteor-reactive-aggregate', // By default, Meteor will default to using README.md for documentation. @@ -14,6 +14,5 @@ Package.onUse(function(api) { api.versionsFrom('1.5'); api.use(['ecmascript', 'underscore', 'mongo', 'sakulstra:aggregate@1.4.3'], ['server']); - api.export('ReactiveAggregate', 'server'); api.mainModule('aggregate.js', 'server'); });