i’m having issues on how to get the list of values from an array one by one dynamic. To pass to aggregate function Collection is like below
{
"_id" : "gBF5yZxHQvfwsnoSJ",
"title" : "Testing",
"status" : "Open",
"createdAt" : ISODate("2017-11-01T06:50:49.626Z"),
"createdBy" : "user",
"questions" : [
{
"qid" : "jBP9SbXFgAnHgwWhX",
"question" : "Are you a Boy or a Girl",
"type" : "radio",
"options" : [
{
"option" : "Boy",
"qid" : "jBP9SbXFgAnHgwWhX"
},
{
"option" : "Girl",
"qid" : "jBP9SbXFgAnHgwWhX"
}
]
},
{
"qid" : "hMDqLSB9QaTuCsNm2",
"question" : "Up or Down",
"type" : "radio",
"options" : [
{
"option" : "Up",
"qid" : "hMDqLSB9QaTuCsNm2"
},
{
"option" : "Down",
"qid" : "hMDqLSB9QaTuCsNm2"
}
]
}
]
}
i want to get “qid” : “hMDqLSB9QaTuCsNm2” and “option” : “Boy” for example… i can do aggregate by specific data or static but i want it to be dynamic qid and option is different always…
Template.result.helpers({
questionList:function(){
var controller = Router.current();
questionId = controller.params._id;
var a = QuestionCollection.find({_id: questionId});
var qid = //??????????
var option = //??????????
//Mateor.call aggregate function here qid option
},
});