How to only subscribe to users who participated on the page?


#1

Currently I am using Iron Router and in my waitOn I want to only subscribe to users who participate on the page in order to minimize the subscription. The page just displays a thing similar to a basic “Post” with comments and what not. My current idea is to have an array stored with each user with the post ids of posts they have contributed to and when I subscribe I’ll just use the post id and find() users based on that, but I don’t think this is the best way to accomplish it. Ideas?


#2

I think you may find this publish-composite useful. It has example code for a very similar problem.

I would rather do the other way round, i.e., store an array of users who have commented/contributed to a post. In doing so, you have all the information about your post in one collection. Or if we take your approach, to display a post in its entirety, you would have to iterate over all the users and check if they have they contributed this post.