I have this code to retrieve array datas from my collection. I managed to split them in other to get the data of each position in the array but now I need each of this data for another query, When i make the query directly after the split I get errors, is there a way of saving the variable mySplitResult[] as a global variable in other to access it from another template helper to make my queries or is there any other way to use the result from mySplitResult for query in the same function. All this am doing in javascript from the client side.
Template.testeo.helpers({
ls: function(){
var list=Calender.find({status_visualizacion: "visible"});
var count = 0;
list.forEach(function(calender){
var result = + count + "," + calender.calendario_slaves;
mySplitResult = result.split(",");
var i = 0;
while (i < mySplitResult.length){
//console.log(mySplitResult[i]);
trozo= mySplitResult[i];
console.log(trozo);
i++;
//return trozo;
}
count += 1;
});
}
});
mySplitResultis being computed in a loop so it has multiple values. Secondly why are you joining strings only to split them again? Ifcalender.calendario_slavesis an array then you can just use it. Thirdly, your helper doesn't return anything (there is a commented outreturnbut its inside thewhileloop so that makes no sense either. What are you actually trying to do?