My inventory consists of various items.
With an overwhelming number of products, I aim to categorize them for a more efficient organization of my publish/subscribe
code (and subsequent updates to templates).
Let's say I have 4 separate collections in my mongodb: balloons, balls, tents, tea.
To streamline this, I plan to group them under newly created foo
and bar
. This way, I can simplify the process by writing two publish/subscribe statements instead of 4. And then, accessing my data will look something like this:
on Client:
Foo = new Meteor.Collection('foo');
Bar = new Meteor.Collection('bar');
in html template
{{#each foo.balloons }}
<p>{{ size }}</p>
<p>{{ price }}</p>
{{/each}}
or in another html template
{{#each bar.tents }}
<p>{{ size }}</p>
<p>{{ price }}</p>
{{/each}}