Skip to content

Instantly share code, notes, and snippets.

@dimitriipro
Created February 3, 2017 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimitriipro/a28ba9f4ee3025a9bf7178cc3051b2a5 to your computer and use it in GitHub Desktop.
Save dimitriipro/a28ba9f4ee3025a9bf7178cc3051b2a5 to your computer and use it in GitHub Desktop.
Dynamically update/set a sub attribute of a Collection in Meteor
//Dynamically update/set a sub attribute of a Collection in Meteor
var $set = {};
$set['profile.' + fieldname] = name;
Meteor.users.update({_id:Meteor.user()._id}, { $set: $set });
/* ECMAScript 6 */
Meteor.users.update(
{ _id: Meteor.user()._id },
{ $set: { ['profile.' + fieldname]: name } }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment