0

I am new to meteor . I am now trying to add a field in to the profile section of Users collection generated by the accounts.password package. I want the field name to be EmplId. Searched in the meteor documentation and found that "The profile is writable by the user by default.If "profile is an Object which the user can create and update with any data" ,can anyone please help me with how the code should be to add a field EmpId in to the Meteor.users collection? Thanks in advance.

Aparna V
  • 179
  • 4
  • 12
  • Try this http://stackoverflow.com/questions/29012836/how-to-partly-update-meteor-users-profile – Andrew Sep 07 '15 at 10:36

1 Answers1

0

While you can add keys to the profile key during Accounts.createUser(), you can also set them later. You simply update the Meteor.users collection as you would any other collection:

Meteor.users.update({ _id: Meteor.userId() },{ $set: { 'profile.emplId': emplId }});

Note that when you refer to sub-keys in a collection you need to quote 'key.subkey' - in this case 'profile.emplId'

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39