This may be a duplicate question but I've yet to find a solution to my specific problem. I have a db set up like this:
{ "_id" : ObjectId("5c43b0e463ad7e8adfa4f07a"), "name" : "The Box", "price" : "80", "parts" : [ { "pname" : "piccolo", "pprice" : "3" }, { "pname" : "Flute 1", "pprice" : "3" } ] }
Is there a way to iterate through the parts array and do a nested {{#each}} loop so that I can display the name of each document and each part within the name? my code so far:
<tbody>
{{#each pieces}}
<tr class="itemList">
<td class="name">{{name}}</td>
<td class="pdf">PDF</td>
<td class="audio">AUDIO</td>
<td class="format">FORMAT</td>
<td class="price" >${{price}}</td>
<td><input class ="qty" type ="number" name ="quantity" value="0"></td>
</tr>
{{#each parts}}
<tr>
<td colspan="3"></td>
<td class="partName">{{pname}}</td>
<td class="partPrice">{{pprice}}</td>
<td><input class="partQty" type="number" name="quantity" value="0"></td>
</tr>
{{/each}}
{{/each}}
</tbody>
and my helpers:
Template.band.helpers({
pieces: function(){
return bandmusic.find({})
},
parts: function(){
return bandmusic.find({parts})
} })