@@ -62,10 +62,11 @@ describe('examples', function() {
6262 var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
6363 var session = driver . session ( ) ;
6464 session
65- . run ( "CREATE (a:Person {name:'Arthur' , title:'King'})" )
65+ . run ( "CREATE (a:Person {name: {name} , title: {title}})" , { name : "Arthur" , title : "King" } )
6666 . then ( function ( )
6767 {
68- return session . run ( "MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title" )
68+ return session . run ( "MATCH (a:Person) WHERE a.name = {name} RETURN a.name AS name, a.title AS title" ,
69+ { name : "Arthur" } )
6970 } )
7071 . then ( function ( result ) {
7172 console . log ( result . records [ 0 ] . get ( "title" ) + " " + result . records [ 0 ] . get ( "name" ) ) ;
@@ -86,7 +87,7 @@ describe('examples', function() {
8687 //end::configuration[]
8788
8889 var s = driver . session ( ) ;
89- s . run ( "CREATE (p:Person { name: {name} })" , { name : "The One" } )
90+ s . run ( "CREATE (p:Person {name: {name}})" , { name : "The One" } )
9091 . then ( function ( result ) {
9192 var theOnesCreated = result . summary . counters . nodesCreated ( ) ;
9293 console . log ( theOnesCreated ) ;
@@ -119,7 +120,7 @@ describe('examples', function() {
119120 var session = sessionGlobal ;
120121 // tag::statement-without-parameters[]
121122 session
122- . run ( "CREATE (p:Person { name: 'Arthur' })" )
123+ . run ( "CREATE (p:Person {name: 'Arthur'})" )
123124 // end::statement-without-parameters[]
124125 . then ( function ( result ) {
125126 var theOnesCreated = result . summary . counters . nodesCreated ( ) ;
@@ -136,12 +137,12 @@ describe('examples', function() {
136137 it ( 'should be able to iterate results' , function ( done ) {
137138 var session = sessionGlobal ;
138139 session
139- . run ( "CREATE (weapon:Weapon { name: ' Sword in the stone' })" )
140+ . run ( "CREATE (weapon:Weapon {name: { name}})" , { name : " Sword in the stone" } )
140141 . then ( function ( ) {
141142 // tag::result-traversal[]
142143 var searchTerm = "Sword" ;
143144 session
144- . run ( "MATCH (weapon:Weapon) WHERE weapon.name CONTAINS {term} RETURN weapon.name" , { term : searchTerm } )
145+ . run ( "MATCH (weapon:Weapon) WHERE weapon.name CONTAINS {term} RETURN weapon.name" , { term : searchTerm } )
145146 . subscribe ( {
146147 onNext : function ( record ) {
147148 console . log ( "" + record . get ( "weapon.name" ) ) ;
@@ -165,12 +166,14 @@ describe('examples', function() {
165166 it ( 'should be able to access records' , function ( done ) {
166167 var session = sessionGlobal ;
167168 session
168- . run ( "CREATE (weapon:Weapon { name: 'Sword in the stone', owner: 'Arthur', material: 'Stone', size: 'Huge' })" )
169+ . run ( "CREATE (weapon:Weapon {name: {name}, owner: {owner}, material: {material}, size: {size}})" ,
170+ { name : "Sword in the stone" , owner : "Arthur" , material : "Stone" , size : "Huge" } )
169171 . then ( function ( ) {
170172 // tag::access-record[]
171173 var searchTerm = "Arthur" ;
172174 session
173- . run ( "MATCH (weapon:Weapon) WHERE weapon.owner CONTAINS {term} RETURN weapon.name, weapon.material, weapon.size" , { term : searchTerm } )
175+ . run ( "MATCH (weapon:Weapon) WHERE weapon.owner CONTAINS {term} RETURN weapon.name, weapon.material, weapon.size" ,
176+ { term : searchTerm } )
174177 . subscribe ( {
175178 onNext : function ( record ) {
176179 var sword = [ ] ;
@@ -201,11 +204,12 @@ describe('examples', function() {
201204 var session = sessionGlobal ;
202205
203206 session
204- . run ( "CREATE (knight:Person:Knight { name: ' Lancelot' , castle: ' Camelot' })" )
207+ . run ( "CREATE (knight:Person:Knight {name: { name}, castle: {castle}})" , { name : " Lancelot" , castle : " Camelot" } )
205208 . then ( function ( ) {
206209 // tag::retain-result[]
207210 session
208- . run ( "MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN knight.name AS name" , { castle : "Camelot" } )
211+ . run ( "MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN knight.name AS name" ,
212+ { castle : "Camelot" } )
209213 . then ( function ( result ) {
210214 var records = [ ] ;
211215 for ( i = 0 ; i < result . records . length ; i ++ ) {
@@ -232,17 +236,19 @@ describe('examples', function() {
232236 it ( 'should be able to do nested queries' , function ( done ) {
233237 var session = sessionGlobal ;
234238 session
235- . run ( "CREATE (knight:Person:Knight { name: 'Lancelot', castle: 'Camelot' })" +
236- "CREATE (king:Person { name: 'Arthur', title: 'King' })" )
239+ . run ( "CREATE (knight:Person:Knight {name: {name1}, castle: {castle}})" +
240+ "CREATE (king:Person {name: {name2}, title: {title}})" ,
241+ { name1 : "Lancelot" , castle : "Camelot" , name2 : "Arthur" , title : "King" } )
237242 . then ( function ( ) {
238243 // tag::nested-statements[]
239244 session
240- . run ( "MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN id(knight) AS knight_id" , { "castle" : "Camelot" } )
245+ . run ( "MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN id(knight) AS knight_id" ,
246+ { castle : "Camelot" } )
241247 . subscribe ( {
242248 onNext : function ( record ) {
243249 session
244250 . run ( "MATCH (knight) WHERE id(knight) = {id} MATCH (king:Person) WHERE king.name = {king} CREATE (knight)-[:DEFENDS]->(king)" ,
245- { "id" : record . get ( "knight_id" ) , " king" : "Arthur" } ) ;
251+ { id : record . get ( "knight_id" ) , king : "Arthur" } ) ;
246252 } ,
247253 onCompleted : function ( ) {
248254 session
@@ -281,7 +287,7 @@ describe('examples', function() {
281287 it ( 'should be able to profile' , function ( done ) {
282288 var session = sessionGlobal ;
283289
284- session . run ( "CREATE (:Person {name:'Arthur'})" ) . then ( function ( ) {
290+ session . run ( "CREATE (:Person {name: {name}})" , { name : "Arthur" } ) . then ( function ( ) {
285291 // tag::result-summary-query-profile[]
286292 session
287293 . run ( "PROFILE MATCH (p:Person {name: {name}}) RETURN id(p)" , { name : "Arthur" } )
@@ -323,7 +329,7 @@ describe('examples', function() {
323329
324330 // tag::transaction-commit[]
325331 var tx = session . beginTransaction ( ) ;
326- tx . run ( "CREATE (:Person {name: 'Guinevere'})" ) ;
332+ tx . run ( "CREATE (:Person {name: {name}})" , { name : "Guinevere" } ) ;
327333 tx . commit ( ) ;
328334 // end::transaction-commit[]
329335 } ) ;
@@ -333,7 +339,7 @@ describe('examples', function() {
333339
334340 // tag::transaction-rollback[]
335341 var tx = session . beginTransaction ( ) ;
336- tx . run ( "CREATE (:Person {name: 'Merlin'})" ) ;
342+ tx . run ( "CREATE (:Person {name: {name}})" , { name : "Merlin" } ) ;
337343 tx . rollback ( ) ;
338344 // end::transaction-rollback[]
339345 } ) ;
0 commit comments