Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does 'mongodb-server-aggregation' work (Meteor)

I'm trying to perform an aggregation on the server part of my meteor application. I've installed the mongodb-server-aggregation package, but when I do a simple aggregation like

var cursor = Tasks.aggregate(
    [
      {
        '$group': {
          '_id': '$code'
        }
      }
    ]
  );

I get the following error

...
TypeError: Cannot call method 'collection' of undefined
     at _futureWrapper (packages/mongodb-server-aggregation/server.coffee:17:31)
...

I probably do something wrong here, but I must say, I cannot find any examples too. Any help would be appreciated?

like image 770
Jeanluca Scaljeri Avatar asked May 26 '26 22:05

Jeanluca Scaljeri


1 Answers

Looking at the package maybe comment out line 5 in server.coffee

MongoDB = Npm.require("mongodb")

Then I think it works.

Also, a bit of a technicality but line 8 has Meteor.Collection which should be Mongo.Collection

If you only need it server side, why use the whole package? Fork it and then roll your own version.

like image 69
Steeve Cannon Avatar answered May 30 '26 05:05

Steeve Cannon