I am trying to understand when you would use the "RETURN session.run" versus the "session.run" in a nested promise (in JavaScript). I have seen examples of both but I am not following the logic for the different usage. I have the following code(pseudo) as an example. I am using Neo4j for my database:
fn=function(data,callback)
{
session
.run(cypherquery)
.then function(result)
{
return session //why a return here...the code seems to work without it!
.run(anothercypherquery1)
.then function(result)
{
for (var i=0; i<result.somearray.length;i++)
{
session //why wouldn't I use a Return here? or should I?
.run(anothercypherquery2)
{}
.then(function(result){})
.catch(function(err){})
}
}
.catch( function(){})
}
.catch(function(){})
Return cb();
}
Each session is dependent on the previous one to complete before proceeding but the return data from the cypherquery is not needed. the scenario would be similar to creating a new record with relationships where first cypher check if record exist already....second cypher create new record...third cypher create relationships in a for loop. I am trying to determine the best way to do this and why? any help would be much appreciated.