I'm working with following document
{
"_id" : 123344223,
"firstName" : "gopal",
"gopal" : [
{
"uuid" : "123",
"name" : "sugun",
"sudeep" : [
{
"uuid" : "add32",
"name" : "ssss"
},
{
"uuid" : "fdg456",
"name" : "gfg"
}
]
},
{
"uuid" : "222",
"name" : "kiran"
}
]
}
I want to retrieve name from the first document of array sudeep and print it in a table...
here is what i have tried
Template.table.helpers({
ProductManager: function () {
return ProductManager.findOne({_id:123344223},{gopal:{$elemMatch:{uuid:"123"}}});
}
})
where ProductManager is my collection and defined in common.js
ProductManager = new Meteor.Collection("ProductManager");
Here is my template
<template name="table">
<table>
<thead>
<tr>
<th>NAME</th>
<th>UUID</th>
</tr>
</thead>
<tbody>
{{#each ProductManager.gopal.sudeep}}
<tr>
<td>{{name}}</td>
<td>{{uuid}}</td>
</tr>
{{/each}}
</tbody>
</table>
when i tried this
ProductManager.findOne({_id:123344223},{gopal:{$elemMatch:{uuid:"123"}}});
Iam able get this in mongo shell
{
"_id" : 123344223,
"gopal" : [
{
"uuid" : "123",
"name" : "sugun",
"sudeep" : [
{
"uuid" : "add32",
"name" : "ssss"
},
{
"uuid" : "fdg456",
"name" : "gfg"
}
]
}
]
}
but cant print name and uuid of "sudeep" in the table....... plzz help me to solve this problem... Thanks in advance