I have a helper, in which i want to get the collection ‘data’, for currently logged user. I do not publish this collection because it has sensitive data, so i want to get the collection via call to server like:
server side:
export const GetData = new ValidatedMethod({
name: 'GetData',
validate: new SimpleSchema({
}).validator(),
run() {
var id = Meteor.userId();
var user = Meteor.users.findOne({_id: id});
if(user)
return Data.find({assigned_id: user.profile.secret_id});
return null;
},
});
this way i get sensitive data only for currently logged user, so its not gonna be abused, but how to call server method from helper?
Template.pageBanks.helpers({
data(){
Meteor.call('GetData', function(err,data){
if(!err)
return data;
});
}
});
This doesn’t work, how can i call server method in helper properly?
EDIT:
I’m aware of solutions using onCreated or RactiveMethod, however they don’t fit, i want to make the helper reactive. Also i have multi user environment, users are working in the same time, so i cant store this in session ( i mean i probably could, but that’s not good practive ) so i need a solution using local reactive var for current template instance.