I have a dashboard with all of the data on my collection and i have a widget which displays the document count, if admin, all documents count, then if non-admin the document count will be based on his profile (company and branch), the guys from publish-count package help me create a publish function.
My question is does checking of roles will run on client or only on server?
Because when i tried to subscribed by checking the user roles, it seems that it didn't run the subscription.
I have this subscription on the client:
var user = Meteor.users.findOne({"_id": this.userId},{fields:{profile: 1}});
var adminRole = Roles.userHasRole(this.userId, "admin");
var hqRole = Roles.userHasRole(this.userId, "HQ");
var branchRole = Roles.userHasRole(this.userId, "Branch");
if (adminRole)
Meteor.subscribe("enrollments", 5);
else if (hqRole)
Meteor.subscribe("enrollmentsByCompany", user.profile.company, 5);
else if (branchRole)
Meteor.subscribe("enrollmentsByBranch", user.profile.branch, 5);
I've console log the count output and gives 0 count.
Is this is something on how do i check the roles or am I missing something or misused?
Hi @nicolaslopezj ,
I have a dashboard with all of the data on my collection and i have a widget which displays the document count, if admin, all documents count, then if non-admin the document count will be based on his profile (company and branch), the guys from publish-count package help me create a publish function.
Here's the publish function:
My question is does checking of roles will run on client or only on server? Because when i tried to subscribed by checking the user roles, it seems that it didn't run the subscription. I have this subscription on the client:
I've console log the count output and gives 0 count.
Is this is something on how do i check the roles or am I missing something or misused?