Meteor在匿名收集客户端更新了几个条目

时间:2014-04-27 07:30:44

标签: meteor minimongo

我在尝试更新匿名集合(客户端)上的所有条目时遇到了意外行为。只更新一个条目而不是全部条目。我希望以下代码返回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)

1 个答案:

答案 0 :(得分: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
相关问题