English 中文(简体)
B. 甲基苯丙胺收集更新的猎物
原标题:Hunting bug in Meteor collection update
  • 时间:2012-04-11 05:53:22
  •  标签:
  • meteor

I’m trying out Meteor’s Leaderboard example and am running into a bug in trying to randomize the players’ scores.

页: 1 在模拟援引/扮演者/更新未定义的的效力时,例外

相关法典也这样做:

 click input.randomize_scores : function () {
  Players.find().forEach(function (player) {
    random_score = Math.floor(Math.random()*10)*5;
    Players.update(player, {$set: {score: random_score}})
  });
}

Full leading板.js content here

我的感觉是,我在这里做的事情令人sil笑.。 我确实赞赏一位协调人。

最佳回答

更新(更新)的第一个论点是文件ID或全刚果甄选者。 你通过完整的参与者文件。 引证:

Players.update(player._id, {$set: {score: random_score}});

简言之,

Players.update({_id: player._id}, {$set: {score: random_score}});
问题回答

暂无回答




相关问题
Problems to run examples in Meteor

I m testing Meteor examples and this is what I see when I run meteor in todos examples: Unexpected mongo exit code 100. Restarting. Unexpected mongo exit code 100. Restarting. Unexpected mongo exit ...

Handlebars Exception

Any hints what the following exception might be about? Running on: http://localhost:3000/ No dependency info in bundle. Filesystem monitoring disabled. Errors prevented startup: Exception while ...

How easy to call external Web APIs in Meteor?

Does (or will) Meteor provide a library to handle external Web API calls? E.g. to build a Meteor app that integrates with Facebook Graph API or Google Spreadsheet API.

Meteor - Using collection on client startup

Why this code shows "0"? Shouldn t it return "1"? Messages = new Meteor.Collection("messages"); if (Meteor.is_client) { Meteor.startup(function () { alert(Messages.find().count()); ...

热门标签