I have more than one million records in mongo collection. It is obviously is bad strategy to send all these record to client browser.
So, I created a publish function which just return count for "Searched" parameter only amongst those million records.
Meteor.publish('count', function(query) {
return Collection.find({ fieldName : "query" }).count();
});
So, I got response from above query in following format.
We are counting for pain and count is [object Object]
I want to show the count from above publication,But I receive objects only in response not number. Though When I executed this same query in dev console then , it did showed "Number" as output.
Where am I going wrong? Can anyone show me a simple example that helps this to resolve?
There is a package for it: https://atmospherejs.com/tmeasday/publish-counts
Simply call Counts.publish within a publication, passing in a name and a cursor:
Subscribe on the client:
Then just call
Counts.get('postsCount');
to get counter number. For example in your helper: