Barry Michael Doyle
Barry Michael Doyle

Reputation: 10658

Meteor manually adding users to roles via mongodb

I've just started using the alanning/meteor-roles package in my meteor project. Is there a way I can add users to a role manually via mongo db?

Because I really don't want to hard code it in because then I'll have to take it out later down the line, it'd be much easier to test the app with the ability to just assign roles to users via mongodb. Is this possible?

After I get that working I can create an interface to do it the code way for admin users.

Note: I'm also not too sure how the users schema works with this roles package so maybe it's an easy solution that I just don't understand with my relatively new experience in making Meteor apps.

Upvotes: 3

Views: 672

Answers (1)

Faysal Ahmed
Faysal Ahmed

Reputation: 1542

alanning:roles package does nothing special in the db.So you can always manually insert different roles of user executing raw query in the database. You'll find the schema of the user database in the documentation of Meteor. alanning:roles package only add a field in the db called 'roles'. so basically your raw query in the mongo would be something like this

db.users.update('mongo_id_here',{$set:{roles:['admin']}})

this is just an illustration. check out the package documentation to know how the package interprets role from db for more advanced query.

Upvotes: 6

Related Questions