U heeft geen client-side collectie. Je moet je ook abonneren voordat je deze helper belt.
Probeer dit
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './main.html';
var clientReport = new Mongo.Collection('clientReport');
Meteor.subscribe("reportTotals");
Template.header.helpers({
'tasks': function () {
console.log("tasks helper called : ");
console.log(clientReport.find().fetch());
},
});
Je hebt ook geen pijplijn en geen autorun op servercode nodig, probeer dit:
AtmData = new Mongo.Collection('atmdata');
Meteor.startup(() => {
// code to run on server at startup
/* AtmData.insert({
bottles_used: 123,
}); */
});
Meteor.publish("reportTotals", function() {
// Remember, ReactiveAggregate doesn't return anything
ReactiveAggregate(this, AtmData, [{
// assuming our Reports collection have the fields: hours, books
$group: {
'_id': null,
'bottles_used': {
// In this case, we're running summation.
$sum: '$bottles_used'
// $sum: 1
}
}
}], { clientCollection: "clientReport" });
});