I’ve added an aggregation to try and get a count from a subcollection, and it’s working, but when i try to put the count on the template, it’s not showing. Not sure where I’m going wrong.
<div class="col s6 countNumber">
{{TotalGifts}}
</div>
Here’s my helper:
TotalGifts: function() {
console.log("Total: ");
Meteor.call('get.totalGifts', function(err, result){
if (err) {
console.log("Error: " + err);
} else {
var count = result[0].count;
console.log(count);
return count;
}
});
},
The console.log works just fine, and shows the correct count…
And, just so you have it, my Aggregation function run on the server.
'get.totalGifts' () {
console.log("getting total gifts:");
var totalGifts = Recipients.aggregate({ $unwind: "$gifts" }, { $group: { _id: '', count: { $sum: 1 }}});
return totalGifts;
},
As always, any help is appreciated.