I have an application that uses Flow Router and its pub/sub mechanics. I also have a collection and template helpers. The code is, on client
Template.theCase.helpers({
theCase: function () {
var id = FlowRouter.getParam('id');
var theCase = Cases.findOne({
id: id
});
return theCase;
}
});
and
{{#with theCase}}
{{ id }}
{{/with}}
then, on server
Meteor.publish('theCase', function (id) {
return Cases.findOne({
id: id
});
});
and finally, on both (lib
)
FlowRouter.route('/case/:id', {
subscriptions: function (params) {
this.register('theCase', Meteor.subscribe('theCase', params.id));
},
action: function (params, queryParams) {
return BlazeLayout.render('container');
}
});
The problem, as I see it, is that helper returns undefined
, since it's not allowed to find items in a collection by any other property than _id
. How can I overcome it? I've read truckload of the official docs on pub/sub, helpers and routing, and I just can't find the solution. Any suggestions?