[SOLVED] Sakulstra:aggregate with Meteor 2.6

Hello,
Did you guys try to use the aggregate package sakulstra:aggregate with meteor 2.6.
According to the migration guide collection.rawCollection().aggregate() has changed and I suspect sakulstra:aggregate is using it.
Thanks for your reply

Hello again,
I have just saw that there is a pull request from @renanccastro

You rock guys!

If the package maintainer does not accept the pull request, does this mean I will have to fork it and copy it locally in my app ?

1 Like

Yes, that would be an option, @dokithonon.

Or maybe try to contact the maintainer to ask them to accept the PR.

ps: we also could add the package to the Meteor Compat Program and do it ourselves.

2 Likes

I had this problem and, to be fair, it’s probably easier to implement it yourself as part of your server side initialisation:

if (Meteor.isServer) {
    // set up a synchronous aggregate capability
    Mongo.Collection.prototype.aggregate = function(pipelines,options) {
        return Meteor.wrapAsync(function(callback) {
            this.rawCollection().aggregate(pipelines,options).toArray().then((result) => callback(null,result), callback);
        },this)();
    };
}

Thanks for your message.
It appears that the repo has been taken over by meteor-compat and that they update the code to make it work with 2.6 : GitHub - meteor-compat/meteor-aggregate: Proper MongoDB aggregations support for Meteor
So it should be all good

1 Like

That’s right @dokithonon! The package author told us to assume it, so we did.

We are looking into adding this form of aggregation support to the Meteor core. For now, you can use the compat package. :slight_smile:

1 Like

Perfect timing. Just this morning I received a bug report from testing :sweat_smile:

1 Like

Hi,

It seems there’s a bug in the new version.

We cannot use ObjectIDs in a $match stage. It never “matches”.
And it’s something that works on Compass/Command line.

For example:

let queryFilter = { _id: new Meteor.Collection.ObjectID('752cffa85f48429f478941cd') };
let DUPsearch = AssistantInvoices.aggregate([{$match: queryFilter}]);

This never matches the document. We’ve also tried with {$in: [new Meteor.Collection.ObjectID(‘752cffa85f48429f478941cd’), new Meteor.Collection.ObjectID(‘111111111111111’)]} and it also does not work ! :frowning:

Any idea what to do ?

Regards,

Burni