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

Romoving users with a certain role #187

Closed da-moon closed 8 years ago

da-moon commented 8 years ago

I am trying to to finish my database seeder. I would like to know if there are any methods that elets all the users from a certain role or group

mitar commented 8 years ago

You mean delete all users from the database which are in some role? Or you mean remove users from a role, but keep them in the database?

For first, for v1.0 you can use Roles.getUsersInRole to get a cursor of all users and then you can iterate over and remove them.

For second you could combine this with removeUsersFromRoles.

In v2.0 you can use Roles._usersInRoleQuery to get a query which you can use directly to remove users from the database.