I'm having a bit of a dilemma concerning how to set up the collections in my Meteor app. The user search bar is a central part of my app, and the user needs to be able to enter one search and have results across several different collections :
user query : 'foo'
var query = 'foo';
var actors_results = Actors.find({ $or : [{ name : query}, { actor_biography : query }] );
var films_results = Films.find({ $or : [{ name : query}, { description : query }] );
var cinemas_results = Cinemas.find({ $or : [{ name : query}, { genres : query }] );
For search results display this is not good - I don't think (???) I can combine these cursors into one cursor, and so simple things like pagination become almost impossible to do (or I don't know how to do it).
The only solution I know would be to make a SuperCollection where I put all of the documents and have a field 'type' which could be 'actor', 'film' or 'cinema', then pagination etc becomes easy.
But it seems to me this really complicates everything else... the structure of the database no longer reflects the data. Actors and Cinemas have nothing in common in terms of data/structure, I just need to be able to search them in parallel.
Also how would I set up multiple validation schemes for the SuperCollection depending on the value of the field 'type' ?
Any ideas/suggestions much appreciated !!!