2013-08-25 182 views
0

我想更新具有可变的帮助下阵,这就是我的源代码:流星:变量变

var y = Flags.findOne({_id: "flagsone"}); 

// This one works, but I need the other one 
// Books.update({_id:book}, {$set: {"score20130901.5": 222}}); 

    Books.update({_id:book}, {$set: {"score20130901.[y.flag1]": 222}}); 

有别人的想法,我怎么能变量放在一起?

回答

0
var y = Flags.findOne({_id: "flagsone"}); 
var props = {}; 
props["score20130901." + y.flag1] = 222; 
Books.update({_id:book}, {$set: props});