1
我想将一个变量乘以几个浮点数插入这样的流星集合中,并在反应表中使用它。它不工作,我不知道我是否可以做到这一点。这里是我的代码:将var乘以一个数字插入到mongo db中
Template.cover.events({
'submit .js-ftp-submit': function(event) {
console.log("Clicked");
var ftp, lthr;
ftp = event.target.ftp.value;
lthr = event.target.lthr.value;
console.log("ftp: " + ftp + " lthr : " + lthr);
if (Meteor.user()) {
Zones.insert({
end_pwr_1: ftp * .56,
end_pwr_2: ftp * .75,
end_hr_1: lthr * .80,
end_hr_2: lthr * .90,
temp_pwr_1: ftp * .76,
temp_pwr_2: ftp * .85,
temp_lthr_1: lthr * .91,
temp_lthr_2: lthr * .95,
ss_pwr_1: ftp * .86,
ss_pwr_2: ftp * .95,
ss_lthr_1: lthr * .96,
ss_lthr_2: lthr * .99,
thresh_pwr_1: ftp * .96,
thresh_pwr_2: ftp * 1.05,
thresh_lthr_1: lthr * 1,
thresh_lthr_2: lthr * 1.02,
vo2_pwr_1: ftp * 1.06,
vo2_pwr_2: ftp * 1.20,
vo2_lthr_1: lthr * 1.03,
vo2_lthr_2: lthr * 1.06,
anaerobic_pwr_1: ftp * 1.21,
anaerobic_pwr_2: ftp * 1.50,
np_pwr_1: "over",
np_pwr_2: ftp * 1.51
});
}
}
});
我可以尝试插入数据库乘以变量? 控制台记录2变量好,但没有在表中。
“它不起作用”是一个可怕的问题描述。它不工作_how_?任何错误? –
没有错误。当我在控制台中执行Zones.findOne()时,我只会得到'undefined'。所以我认为它不工作。我是编程新手。 –
然后,也许'Meteor.user()'返回falsy值,所以你的插入永远不会运行。 –