【发布时间】:2014-11-05 20:55:43
【问题描述】:
我有以下文件:
{
"gameName":"Shooter",
"details":[
{
"submitted":1415215991387,
"author":"XYZ",
"subPlayer":{
"members":{
"squad1":[
{
"username":"John",
"deaths":0
}
]
},
"gameSlug":"0-shooter"
}
}
],
"userId":"foL9NpoZFq9AYmXyj",
"author":"Peter",
"submitted":1415215991608,
"lastModified":1415215991608,
"participants":[
"CXRR4sGf5AdvSjdgc",
"foL9NpoZFq9AYmXyj"
],
"slug":"1-shooterConv",
"_id":"p2QQ4TBwidjeZX6YS"
}
...和下面的 Meteor 方法:
Meteor.methods({
updateDeaths: function(gameSlug, user, squad) {
Stats.update({details.subPlayer.gameSlug: gameSlug}, ...}); // ???
}
});
我的目标是更新字段deaths。该方法有参数user,它是用户对象(用户名=user.username)。此外,参数squad 是字符串形式的小队名称,例如squad1.
我该怎么做?
任何帮助将不胜感激。
【问题讨论】:
标签: javascript mongodb meteor