How to use separately 2 subscriptions in one template (or in parent/child templates)?


#1

I have “search” page, which subscribes to articles by “searchFor” field. Now I want to attach to each article in the list links to other articles by searching in whole Articles collection, but template sees only results of parent subscription.
How to subscribe from child template to articles, different from parent template subscription?


#2

Just subscribe in your child template for same collection, either to same publication with different parameters or a different publication. Subscribed docs will be added to the docs subscribed by the parent template subscription.


#3

Thanks. Yes, it’s the way . First my problem was, that all parameters of articles list was in publication, and in helper was only articles.find({}), when I added new subscription, list of articles became not relevant. Then I changed in helper articles.find({ myCondition}) and then it’s ok :slight_smile:


#4

It’s usually better to do search and filtering using client side conditions rather than using arguments to a subscription.

This article explains better than I can which bits of data management belong where:


#5

Unless I misunderstand what you mean, I disagree. This is not a one or the other choice. It should really be both in most cases. Generally you should subscribe only to subset of the data you require from a collection, meaning you have to pass parameters to the publication, otherwise you are probably increasing both network data volumes, server side resources and client side memory usage at least (generally, but there are of course exceptions). Then you should also query the data from minimongo on the UI template. And oftentimes the query need to be the same (as Sashko’s article mentions).


#6

True. It’s just been my experience that a lot of applications don’t have so much data that you need to be overly aggressive in filtering on the server side and changing those filters frequently. It often just depends on the size of the dataset

I don’t have a lot of experience with search though, and thinking about it again, sending through all the data so it can be searched is probably a bad idea