小编sta*_*qmi的帖子

Meteors集合游标forEach无法正常工作

为什么Meteor集合游标foreach循环在下面的代码中不起作用.如果我将循环包装在Template.messages.rendered或Deps.autorun函数中,它就可以工作.我不明白为什么.

Messages = new Meteor.Collection("messages");

processed_data = [];

if(Meteor.isClient) {

    data = Messages.find({}, { sort: { time: 1 }});
    data.forEach(function(row) {
        console.log(row.name)
        processed_data.push(row.name);
    });
}
Run Code Online (Sandbox Code Playgroud)

collections foreach cursor meteor

7
推荐指数
1
解决办法
7921
查看次数

标签 统计

collections ×1

cursor ×1

foreach ×1

meteor ×1