Count data from collection


Hi, anyone please i need you help. I have create code to count variable in collection. I can get the result when count one by one but not by group. Thats my code, I want to count this but the code not given any resut to me. I want the result like this:


This my code:

{{#each profil}}

Jenis Peralatan Kuantiti
{{PTR}} {{KOM}}

Template.laporankategori.helpers({ profil: function() { return Profil.find({kategori: { $in: ['PTR', 'KOM'] } }).count(); } });


You can use publish count package.


Beside use this pakage, can you suggest to me how to use a manually.


i think this package is easy to use. you dont have to write your own code all the times.

Meteor.publish("countProductByCategory", function(categoryId) {
  Counts.publish(this, 'productCount', Restaurant.Collection.Products.find({
    categoryId: categoryId

//using in template helper

{{getPublishedCount 'productCount'}}

//using in js file


Note: After finish publish you need to rerun your server.