1
因此,我試圖實現的是更新user.profile
,以保留user.profile
中已存在的舊未更新數據。用流星中的動態對象更新user.profile
所以,我最初的user.profile
有以下幾點:
{
accountType: 'Student',
xyz: 'something',
etc...
}
在我更新的方法,我想繼續,如果不需要更新這些值,所以如果我想添加以下內容:
{
'xyz': 'something else',
'bar': 'bar',
etc...
}
我希望看到兩個對象合併和更新後的更新配置文件。
我試圖用是update
和upsert
,但在這兩種情況下,我的所有的測試,當我嘗試更新user.profile
舊數據得到完全被新的數據替換...
這裏是我的一個最新的嘗試:
Meteor.users.update(this.userId, {
$set: {
profile: data
}
},
{ upsert: true });
,但我也試過:
Meteor.users.upsert(this.userId, {
$set: {
profile: data
}
});
我如何能實現我需要什麼?由於
真棒,我非常喜歡這個方案。它充當魅力!乾杯! –