I'm building a page on a meteor site that lists the documents of a collection. The collection is stored in a variable called Tools and has a field named "categories". At the top of this page, I want to have buttons that correspond to the categories; when the button is active, the documents of that category show up. When a button is not active, the documents of that category do not show up.
The thing that's throwing me is that I want to set it up so that you can select multiple categories at once.
To hard code the mongodb query to return multiple category would be something like:
Tools.find(
{ $or:
[
{ category: 'tech' },
{ category: 'creative' }
]
}
);
But I can't figure out how to write this query such that it updates according to Session variables.
As for the Session variables themselves, would it be better to have a boolean variable for each category? As in...
Session.set('tech', true);
Session.set('creative', false);
//etc...
Or would it be better to store them in an array? As in...
Session.set('categories', ['tech', 'creative']);
Thanks in advance!