Perhaps this structure is not a good fit for Meteor, or maybe I’m thinking about it wrong.
Is trying to do a relation like this bad in a noSQL db?
I have Dropzone and Widget collections. A Dropzone can have many widgets, and each widget can exist in more than one dropzone.
My problem is that I can’t seem to make Handlebars render the filtered list of widgets.
My dropzone model
dropzone =
_id: "area1-id"
title: "Area 1"
Widget model (abbreviated)
widget =
_id: "widget1-id"
title: "My Widget"
dropzones: ['area1-id', 'area2-id']
# each widget stores an id of which dropzones it's associated with
Relevant template structure
{{#each dropzones}}
<div class="dropzone span4">
<h1>{{title}}</h1>
<div class="widget-area">
<div class="hotzone">
{{#widgets _id}} # passing in the current dropzone id
{{/widgets}}
</div>
</div>
</div>
{{/each}}
Helper Function
# returns the correct sets of widgets, but can't figure
# out how to make it render the widget partial
Handlebars.registerHelper 'widgets', (drop_id)->
widgets = CC.Widgets.find(dropzones: drop_id)
_.each widgets, (widget)->
Template.widget(widget) # this ends up being blank with no error
I think what you want looks a little more like this:
Helper:
Does that help?