【发布时间】:2015-03-23 00:37:47
【问题描述】:
每次用户订阅“街道”或其他“用户”时,我都想将他们的 ID 添加到当前用户的个人资料中的嵌套对象中。
我尝试了以下不同的结果:
Meteor.users.update(Meteor.userId(), {
$addToSet: {
'profile.subscription': { Street : streetDis
}
}
})
这会更新配置文件,但每次都会在数组中创建一个条目:
Profile.subscription[0] : Street : "eziajepozjaoeja"
Profile.subscription[1] : Street : "eezapoezkaejz"
Profile.subscription[2] : User : "akzejpazjepza"
我想要的架构如下:
Profile.subscription.Street[0] : "eziajepozjaoeja"
Profile.subscription.Street[1]:"eezapoezkaejz"
Profile.subscription.User[0]: "akzejpazjepza"
所以我试试:
Meteor.users.update(Meteor.userId(), {
$addToSet: {
'a.profile.last.Adress': "akzejpazjepza"}
}
)
返回:更新失败:访问被拒绝
Meteor.users.update(Meteor.userId(), {
$addToSet: {
'a.profile': { last: {Adress : "akzejpazjepza"}}
}
})
这也会返回:更新失败:访问被拒绝
【问题讨论】: