例如,我必须这样:
Router.route('/threadList', {
waitOn: function () {
return Meteor.subscribe('threads', Meteor.userId);
},
data: function() {
threads = Threads.find();
_.each(threads, function(thread) {
_.each(thread.comments, function(commentId) {
Meteor.subscribe('comments', commentId);
})
})
}
我不知道如何在Meteor中做这种事情
答案 0 :(得分:0)
您可以查看包publish-composite
在您的出版物代码中执行反应性连接。
只需将其添加到您的项目中:meteor add reywood:publish-composite
然后像你这样发布:
Meteor.publishComposite('publishName', {
find: function() {
return Threads.find({userId: this.userId});
},
children: [
{
find: function(thread) {
return Comments.find({threadId: thread._id});
}
}
});