dhia
May 7, 2016, 3:25am
1
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:
PTR 1
KOM 4
This my code:
`
Jenis Peralatan
Kuantiti
{{#each profil}}
{{PTR}}
{{KOM}}
{{/each}}
`
//js
Template.laporankategori.helpers({ profil: function() { return Profil.find({kategori: { $in: ['PTR', 'KOM'] } }).count(); } });
dhia
May 7, 2016, 4:01am
3
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.
//publish
Meteor.publish("countProductByCategory", function(categoryId) {
Counts.publish(this, 'productCount', Restaurant.Collection.Products.find({
categoryId: categoryId
}));
this.ready();
});
//using in template helper
{{getPublishedCount 'productCount'}}
//using in js file
Counts.get('productCount')
Note: After finish publish you need to rerun your server.
1 Like