Basics:
var obj = {key: 'value'}; //prints {key: "value"}
var obj2 = {};
var key = 'someKey';
obj2[key] = 'someValue';
//{someKey: 'someValue'}
Try this: (You have to use []
for that.)
for(var key in resp.updated_items){
var set = {profile: {}};
set.profile[key] = resp.updated_items[key];
Meteor.users.update({backend_id: Meteor.user().backend_id},
{$set: set});
}
I am not able to remeber how set
works in meteor. But in mongo, you have to do something like this:
for(var key in resp.updated_items){
var set = {};
set['profile.' + key] = resp.updated_items[key];
Meteor.users.update({backend_id: Meteor.user().backend_id},
{$set: set});
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…