Fred J.
Fred J.

Reputation: 6019

Meteor user profile update

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

Answers (1)

chazsolo
chazsolo

Reputation: 8429

Your syntax is close. You must wrap nested properties in quotes:

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

Upvotes: 1

Related Questions