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 12fffd6..cb964c8 100644 --- a/aggregate.js +++ b/aggregate.js @@ -12,7 +12,7 @@ const defaultOptions = ({ ...options }); -export const 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/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..6c411e5 100644 --- a/package.js +++ b/package.js @@ -1,19 +1,18 @@ 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.", + 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.mainModule('aggregate.js', 'server'); });