Meteor-Community-Packages / meteor-roles

Authorization package for Meteor, compatible with built-in accounts packages
http://meteor-community-packages.github.io/meteor-roles/
MIT License
920 stars 164 forks source link

Handle large role collection by persisting on client when user is logged it. #332

Open danyhiol opened 3 years ago

danyhiol commented 3 years ago

I have a very complex and large role collection. Since these permissions are needed when the user is logged in, it takes quite some time for my application to load. I have more than 300 inherited roles and this may actually grow larger. Is there a way to persist roles on the client and only read from the client as long as the user is logged in? This package actually helps in persisting the roles on the client. But how can I connect the role package to this persisted collection on the client?

SimonSimCity commented 3 years ago

I don't know if I quite correctly understand the problem you're facing. Would disabling the synchronization of the roles collection fix it? You'd then be responsible yourself to see whether and when you need it and publish it (see https://github.com/Meteor-Community-Packages/meteor-roles/issues/256).

danyhiol commented 3 years ago

The main idea is to get the subscription only once when the user is connected. And persist the data on the client and use them from there. If disabling synchronization doesn't stop the roles from working, then yes.

SimonSimCity commented 3 years ago

Thanks for the response. To me, personally, this is an improvement Meteor should bring. It might also be already suficcient to transfer as little data as possible to the client - maybe you can do what you want already by omitting the roles alltogether or focus on using methods when you have to access/query a vast amount of data.