Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top