Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to save children inside the parent node's save callback #13

Open
eric-leihe opened this issue Mar 2, 2016 · 0 comments
Open

Comments

@eric-leihe
Copy link

Here is my code to create the tree:

`var Bob = new User({ name: 'Bob' });
var Carl = new User({ name: 'Carl' });
Carl.parent = Bob;

Bob.save(function(){
Carl.save(function(){
console.log(Carl);
});
});`

But the inner save of Carl like a blackhole, it never get returned and the console.log never got called.

I dig into the lib/tree.js and finally find that at line 45, "priviousePath" variable is undefined, I think the if condition to enter this block should also check the value of previousPath,
if(isParentChange && previousPath !== undefined ) { // When the parent is changed we must rewrite all children paths as well self.collection.find({ path : { '$regex' : '^' + previousPath + pathSeparator } }, function(err, cursor) { if(err) return next(err);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant