Meteor: How should I update the Users collection to include a new attribute in the object / dictionary? Meteor: How should I update the Users collection to include a new attribute in the object / dictionary? mongodb mongodb

Meteor: How should I update the Users collection to include a new attribute in the object / dictionary?


You're not supposed to change the root fields of the user object:

Meteor.users.update(user, {$set: {"profile.currentHotel": "something"}});

Read more here: http://docs.meteor.com/#/full/meteor_users

EDIT: This answer has become irrelevant as shown in the latest documentation: https://guide.meteor.com/accounts.html#dont-use-profile

This answer is more than 1 year old :) As it turns out, forcing to write user-specific fields under a 'profile' field as some serious security implications (like I always thought) since it gives permission to the clients to modify those sub-fields. So yes, you can set fields in the root object, but be aware that fields that should not be modified by the client, should be under a field without write permissions (or else it falls under the same problem).