3

I need to make a query using aggregate in the MongoDB, but as the meteor does not support'm trying to use the extension server-aggregation. I'm using the code on the server like this:

var result = aggregates('publicadores',[{$match: {_id : _id}},{ $unwind: '$relatorios' },{ $sort: {'relatorios.mes': -1 }}]);

The consultation is being done correctly, but when passing data by Publish Meteor is returning the following error:

Exception from sub MvPSGj5bf2jHFsRng Error: Publish function returned an array of non-Cursors

Does anyone know how to resolve this error, or some other way to apply the aggregate in Meteor?

Murilo Venturoso
  • 359
  • 5
  • 16
  • What MongoDB version are you using, there was a change recently that meant the output of aggregate has changed, it seems the error is moaning about that – Sammaye Jun 25 '14 at 14:21
  • possible duplicate of [Average Aggregation Queries in Meteor](http://stackoverflow.com/questions/18520567/average-aggregation-queries-in-meteor) – Andrew Mao Jun 25 '14 at 14:24
  • I'm using version 2.4.9 of MongoDB, but the aggregate command works, the error happens when the meteor tries to pass the result by PubSub – Murilo Venturoso Jun 25 '14 at 15:56
  • It seems that it will take so that I can make the aggregate function in Meteor. But I managed to solve my problem in another way. Did the normal query in mongo using Meteor and the client created a helper for grouping and sorting. Do not know if it's the best way, but're working. Thanks guys – Murilo Venturoso Jun 25 '14 at 17:07
  • @MuriloVenturoso can you share work around – Abdul Hameed Mar 21 '16 at 10:55

1 Answers1

1

You can try https://atmospherejs.com/meteorhacks/aggregate packages for MongoDB

Sivailango
  • 544
  • 1
  • 6
  • 15