Reputation: 6019
This Meteor client code is trying to update the current user profile with a new property header
if it does not exist and asign to it a value from a variable menuShortName
The below code is crashing the app, it does not like ['header']
How can it be done? Thanks
I need to have both server and client be able to modify this value.
Meteor.users.update({_id: userId},{$set: {profile['header']: menuShortName}});
Upvotes: 0
Views: 178
Reputation: 8429
Your syntax is close. You must wrap nested properties in quotes:
Meteor.users.update({_id: userId}, {$set: {'profile.header': menuShortName}});
Upvotes: 1