1

尝试更新匿名集合(客户端)上的所有条目时出现意外行为。只更新一个条目而不是全部。我希望以下代码返回 true,但事实并非如此:

TEST = new Meteor.Collection(null); // create the anonymous collection client side
TEST.insert({"val":true}); // add a minimal entry
TEST.insert({"val":true}); // add a second minimal entry
TEST.update({}, {"val":false}); // I expect to update all the entries to {"val":false}
TEST.find({"val":true}).count() === 0; // the count gives 1, only the first entry was updated (expected 0)

这要么是一个错误,要么是我没有得到的关于更新的东西……有人能澄清一下吗?注意:显然代码必须复制粘贴到运行 Meteor 的浏览器的控制台中。(在 0.8.0.1 上试过)

4

1 回答 1

1

好的,知道了……我只是忘了使用该{multi:true}选项……真丢脸

TEST = new Meteor.Collection(null);
TEST.insert({"val":true});
TEST.insert({"val":true});
TEST.update({}, {"val":false}, {multi:true});
TEST.find({"val":true}).count() === 0; // works
于 2014-04-27T07:34:40.347 回答