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
921 stars 168 forks source link

Readme.MD vs. YUIDoc vs. Inverse functions #180

Closed hanskohls closed 8 years ago

hanskohls commented 8 years ago

Hi,

I find this package really useful, but am slightly confused. There are a fair few elements the YIDDoc API that are completely omitted from the documentation.

Examples are getGroupsForUser or removeUsersFromRoles. I assume these are all fine to be used?

If it's desired I'd be happy to edit some of the documentation and create a pull request.

I'm also lacking clarity if roles and groups should be defined/removed explicitly with createRole or deleteRole or if implicit definition

On a similar note, I find it frustrating that while the exact inverse functions do exist the 'matrix' seems incomplete. In my case, I assign client users to the client in the form of a group and want to compare the groups I have with the clients I have but there is no function like getGroupsForRole, so I cannot test if there is at least one editor for every client.

Again, I can create a pull request if you'd be happy with this being added.

alanning commented 8 years ago

Hi @hanskohls, the readme has some examples and description but it does not go into every function which is available, since that is what the API docs are for. The API docs do have documentation for getGroupsForUser and removeUsersFromRoles.

Regarding use of createRole and deleteRole, they are optional in the current version of roles. In v2.0, createRole will be required (I believe for performance reasons although I need to check on that).

In the current version of roles, a getGroupsForRole function would be a terribly expensive operation to run. If I'm understanding the expected output, it would require a complete traversal of the entire users collection and would not be something that I'd feel comfortable exposing in the general case. Implementing it for your app may make sense for your use case, though. You can do so by creating your function and setting it directly on the Roles object.

You may also be interested in checking out the v2.0 branch of roles.