This is probably a simple question to answer, so I hope I’ve phrased it clearly…
I have a large collection consisting of documents with a relatively complex schema. On the client, I need to be able to search this collection and return results for combinations of values (for instance, search for documents that match chosen values for ‘age’,‘gender’ and ‘location’).
Now, I obviously don’t want to publish the whole collection to the client. However, how can I only publish and subscribe to a subset if I need to be able to search through the entire server-side collection for all documents that match the given search criteria?
So for instance, if I only want to publish ten results matching my multiple search criteria at a time (and then increments of ten more via some or other pagination system), how would I write my publication and and subscribe functions? I’m imagining I would I do all the heavy lifting on the server by passing all the search variables to the server-side publication function and returning a limited set of results (ten), but then what happens when I request more results via pagination? Do I stop the current subscription (SubscriptionName.stop()) and create a new one with a skip variable every time I call the pagination function? That doesn’t seem right to me. Is there some sort of reactive variable I set that the server picks up and uses to automatically send more data?
If this sounds confusing, it’s probably because I’m confused! I can write some pseudo-code if that helps clarify my question. In short though, I’m looking for a pattern that works for returning collection data based on multiple search criteria in a way that’s compatible with pagination (i.e. get the first ten matches, then the next ten, then the next ten…)