Problem in calling a method recursively in nodejs mongodb [closed]
- by Nilesh
I am trying to create a tree using nodejs and mongodb.Wanted to show a path of a particulr node from the root.So I am finding the destination path and looping back to its parent iteratively until the root.So this is the snippet I am using which results in infinite looping
articleProvider.finditsparent(t,function(error,tap){
if(tap[0].parent=='null')
{
t=(tap[0].parent);
console.log(n);
}
else
{
n.push(tap[0].parent);
console.log(tap[0].parent);
t=(tap[0].parent);
res.send(n);
}
});
res.send(n);
});
How should I get rid of this problem?Is there any way to call it recursively?