So I'm trying to add an 'account_type' field to the user collection.
Meteor.startup(function () {
if (Meteor.users.find().count() === 0){
var user = Accounts.createUser({
email: 'email@fake.com',
password: 'password'
});
Meteor.users.update({_id: user}, {$set : {account_type: 'admin'}});
}
});
When I call Meteor.user().account_type
, it's undefined.
I also read somewhere that something like this may be necessary:
Meteor.methods({
get_user: function(user_id){
return Meteor.users().find({ _id: user_id}, {fields: {account_type: 1}});
}
});
But I get undefined again when I call it:
console.log(Meteor.call('get_user', Meteor.userId()));
What is the proper way to add to the user model?