Reputation: 767
I am finding neo4j3.0 bolt neo4j-driver syntax very challenging. my session code just won't execute, apparently it get skipped. I have created a little test code using the example from the developers manual and surprise surprise it did the same thing. I used node-inspector to look at the code and sure enough it just skipped the "session" block. obviously I am doing something wrong...can someone tell me what it is??...the code is below:.....the code printed only the first console.log then quit.
var neo4j = require('neo4j-driver').v1;
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "allin4k"));
var session = driver.session();
console.log("start session");
session
.run( "CREATE (a:Person {name:'Arthur', title:'King'})" )
.then( function()
{
console.log("return from second session")
return session.run( "MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title" )
})
.then( function( result ) {
console.log( result.records[0].get("title") + " " + result.records[0].get("name") );
session.close();
driver.close();
})
Upvotes: 3
Views: 1438
Reputation: 41676
Not really sure what you're expecting.
With the results of the session you run a second statement on the same session while at the same time you close it?
Your second then
should be at the second call:
var neo4j = require('neo4j-driver').v1;
var driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "allin4k"));
var session = driver.session();
console.log("start session");
session
.run( "CREATE (a:Person {name:'Arthur', title:'King'})" )
.then( function()
{
console.log("return from second session")
session.run( "MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title" ).then( function( result ) {
console.log( result.records[0].get("title") + " " + result.records[0].get("name") );
session.close();
driver.close();
})
})
Upvotes: 2