Chet
Chet

Reputation: 19849

Can I define a new key for Meteor.users Collection?

I want to add more functionality to the users collection. For example:

user.priviledges = ['admin']

or anything else...

Upvotes: 1

Views: 174

Answers (2)

Tarang
Tarang

Reputation: 75945

Yes you can. Just run it as you would with Meteor.users

For instance for the user with id 1234

Meteor.users.update({_id: '1234'}, {$set: {priviledges: ['admin'] } });

Be sure to set .allow rules if you're doing this from the client.

But as mentioned in the comments the best for these role type properties use the meteor-roles package on atmosphere.

Upvotes: 1

delibalta
delibalta

Reputation: 298

You can do it when registering a new user.

Accounts.onCreateUser(function (options, user) {
    user.profile    = {
        name    : "Ugur",
        surname : "Toprakdeviren",
                    sex     : true
    };

   return user;
});

Upvotes: 1

Related Questions