Changes between 2.x and 3.0
Breaking changes
-
The roles a user has assigned are no longer stored in the collection
usersbut have been moved to a separate collection calledrole-assignment, available atMeteor.roleAssignment. You might need to update your schema and places you access the collections directly. -
The roles a user has are not published automatically anymore. If you want all the roles a user has to be published automatically you can use the following code:
Meteor.publish(null, function () { if (this.userId) { return Meteor.roleAssignment.find({ 'user._id': this.userId }); } else { this.ready() } }) -
The behavior of
getRolesForUser()used with the optionfullObjectshas changed. If you need the old behavior, use the code of this change-set: Meteor-Community-Packages/meteor-roles/#41d2ed493852f21cf508b5b0b76e4f8a09ae8f5c
New options
-
removeUsersFromRoles()got the optionanyScopeto remove all the roles a user has. -
getRolesForUser()got the new optiononlyScopedto limiting the result to only scoped permissions
Details and reasoning can be found in #270 and #276
Migration to 3.0
If you are currently using this package in a version older than 2.x, please upgrade to 2.0 first by running the migration script: GitHub - Meteor-Community-Packages/meteor-roles at v2
In meteor-roles 3.0, roles are stored differently in the database. To migrate the database to the new schema, run Meteor._forwardMigrate2() on the server. Please take a backup of the users collection before migrating.
meteor shell
> Package['alanning:roles'].Roles._forwardMigrate2()
In case something fails, there is also a script available for rolling back the changes. But be warned that a backward migration takes a magnitude longer than a forward migration. To migrate the database back to the old schema, run Meteor._backwardMigrate2() on the server:
meteor shell
> Package['alanning:roles'].Roles._backwardMigrate2()
Future of 1.x and 2.x
If you want to keep using this package in version 1.x or 2.x, I’ll support them as good as I can and help you fixing bugs and keep them compatible with upcoming Meteor versions as I can, but all future development will be focussed on the latest major version.
Going forward
At first I want to give the credits and a big thanks to @alanning and @mitar for developing the package so far. Both mentioned in #270 that their time on developing this package got very limited, which is the reason why I picked it up after moving it into the Meteor Community Packages group.
I already have some plans for the next major version in mind which will focus on tree-shaking. In all our versions, roles have been stored in a collection accessible at Meteor.roles, but this collection could equally well be imported when you want it.
I would really appreciate if this package could be an example of collaboration and team effort. Every kind of help is appreciated and very welcome!
Thanks also to @storyteller for proofreading this ![]()
