I'm very new to Meteor, so this question might sound awkward. I'm trying to display a list of all posts
Posts = new Meteor.Collection('posts');
and then in Meteor.publish('posts', ...)
return Posts.find();
and show a number of comments related to each of those posts. Comments are stored in a separate collection
Comments = new Meteor.Collection('comments')
I don't want users to download all comments from the database just to find out comments count for each of the posts - I'm not displaying them here. So
Meteor.publish('comments', function(){
return Comments.find();
})
is not an option.
I know I could denormalize the data and store commentsCount in Post documents. But is there any other way to do this? I'd like it to be observable - or rather live updating, of course. I know how to do it when displaying a single post, but I don't know how to do it for the whole list.