I want to render a reactive template based on this document:
Sprint:
WorkStories:
Tasks
I know this can be done by making a Meteor collection for each “level,” but that means the result is actually being stored as a seperate document in the database. I want to know if its possible to have one collection/document for Sprint, that has standard collection of WorkStories with a standard collection of Tasks each, rendered to a reactive template.
I’ve seen [Meteor.deps.Context][1], but I can’t figure out how to wire it up (or even if it’s the right tool), and none of the examples do anything like this.
I’ve also seen [this question][2], but he seems to be asking about connecting related-but-separate documents, not rendering a single document.
Because database queries on collections are already reactive variables on the client, the below will render one
Sprintdocument with nestedWorkStoriesthat has nestedTasksin a template:HTML:
Javascript:
UPDATE WITH ANSWER
Per @Paul-Young’s comment below, the problem with my usage of
$setwas the lack of quotes in the update. Once the nested object renders in theTemplate, as of Meteor 0.5.3 you can update sub arrays simply:BACKGROUND INFO
This does load the initial object, but updating seems problematic. I was able to get the Template to rerender by calling the below in the console:
Which follows these rules, per the Meteor Docs:
Of course, what you want is to use the
$setstyle operators on nested documents and get the templates to re-render when their nested properties change without having to replace the entire document in the table. The 0.5.3 version of Meteor included the ability to search for sub-arrays:Allow querying specific array elements (foo.1.bar).I’ve tried to do the
.sub array search and haven’t been able to update theWorkStoriessubdocument of the original entity yet, so I posted a question in the google talk.Hope this helps