2013-08-25 145 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});