Publish meteorhacks:aggregate not working in my project


Hi, I need someone help to solve my problem. I have create some code using meteorhacks but i still cannot display the result. Can someone help me. This I sharing my code:
Meteor.publish("profil", function() { var groupedKategori = Profil.aggregate({ $group: { _id: "$kategori", count:{$sum:1}}}); groupedKategori.forEach(function(kategori) { console.log(kategori); }); });
` {{#each groupedKategori}}

{{kategori}} {{/each}}`

Template.laporankategori.helpers({ groupedKategori: function() { var currentUserId =this._id; return Profil.find({kategori: currentUserId}); }, });


Aggregations don’t work very well in publications. It might be better to do that sort of thing in a background job, and insert that into some other collection that you can just publish reactively more easily.

I’d recommend learning Meteor its pub-sub system a little before trying stuff like this.


You can use this reactive aggregate package. It uses publication and stores the aggregated data in client collection. Read this blog post to see how the author uses the package.