Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new mongo driver v4 #8

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
wrapAsync = Meteor.wrapAsync || Meteor._wrapAsync;

Mongo.Collection.prototype.aggregate = function(pipelines, options) {
var coll;
let coll;
if (this.rawCollection) {
// >= Meteor 1.0.4
coll = this.rawCollection();
Expand All @@ -10,8 +10,13 @@ Mongo.Collection.prototype.aggregate = function(pipelines, options) {
coll = this._getCollection();
}
if (MongoInternals.NpmModules.mongodb.version[0] === '3') {
var cursor = wrapAsync(coll.aggregate, coll)(pipelines, options);
const cursor = wrapAsync(coll.aggregate, coll)(pipelines, options);
return wrapAsync(cursor.toArray, cursor)();
}
if (MongoInternals.NpmModules.mongodb.version[0] === '4'){
const cursor = coll.aggregate(pipelines, options);
return wrapAsync(cursor.toArray, cursor)();
}

return wrapAsync(coll.aggregate.bind(coll))(pipelines, options);
};
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
summary: 'Proper MongoDB aggregations support for Meteor',
version: '1.4.3',
version: '1.4.4',
git: 'https://github.com/sakulstra/meteor-aggregate',
name: 'sakulstra:aggregate'
});
Expand Down