@@ -62,10 +62,11 @@ describe('examples', function() {
62
62
var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
63
63
var session = driver . session ( ) ;
64
64
session
65
- . run ( "CREATE (a:Person {name:'Arthur' , title:'King'})" )
65
+ . run ( "CREATE (a:Person {name: {name} , title: {title}})" , { name : "Arthur" , title : "King" } )
66
66
. then ( function ( )
67
67
{
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" } )
69
70
} )
70
71
. then ( function ( result ) {
71
72
console . log ( result . records [ 0 ] . get ( "title" ) + " " + result . records [ 0 ] . get ( "name" ) ) ;
@@ -86,7 +87,7 @@ describe('examples', function() {
86
87
//end::configuration[]
87
88
88
89
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" } )
90
91
. then ( function ( result ) {
91
92
var theOnesCreated = result . summary . counters . nodesCreated ( ) ;
92
93
console . log ( theOnesCreated ) ;
@@ -119,7 +120,7 @@ describe('examples', function() {
119
120
var session = sessionGlobal ;
120
121
// tag::statement-without-parameters[]
121
122
session
122
- . run ( "CREATE (p:Person { name: 'Arthur' })" )
123
+ . run ( "CREATE (p:Person {name: 'Arthur'})" )
123
124
// end::statement-without-parameters[]
124
125
. then ( function ( result ) {
125
126
var theOnesCreated = result . summary . counters . nodesCreated ( ) ;
@@ -136,12 +137,12 @@ describe('examples', function() {
136
137
it ( 'should be able to iterate results' , function ( done ) {
137
138
var session = sessionGlobal ;
138
139
session
139
- . run ( "CREATE (weapon:Weapon { name: ' Sword in the stone' })" )
140
+ . run ( "CREATE (weapon:Weapon {name: { name}})" , { name : " Sword in the stone" } )
140
141
. then ( function ( ) {
141
142
// tag::result-traversal[]
142
143
var searchTerm = "Sword" ;
143
144
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 } )
145
146
. subscribe ( {
146
147
onNext : function ( record ) {
147
148
console . log ( "" + record . get ( "weapon.name" ) ) ;
@@ -165,12 +166,14 @@ describe('examples', function() {
165
166
it ( 'should be able to access records' , function ( done ) {
166
167
var session = sessionGlobal ;
167
168
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" } )
169
171
. then ( function ( ) {
170
172
// tag::access-record[]
171
173
var searchTerm = "Arthur" ;
172
174
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 } )
174
177
. subscribe ( {
175
178
onNext : function ( record ) {
176
179
var sword = [ ] ;
@@ -201,11 +204,12 @@ describe('examples', function() {
201
204
var session = sessionGlobal ;
202
205
203
206
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" } )
205
208
. then ( function ( ) {
206
209
// tag::retain-result[]
207
210
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" } )
209
213
. then ( function ( result ) {
210
214
var records = [ ] ;
211
215
for ( i = 0 ; i < result . records . length ; i ++ ) {
@@ -232,17 +236,19 @@ describe('examples', function() {
232
236
it ( 'should be able to do nested queries' , function ( done ) {
233
237
var session = sessionGlobal ;
234
238
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" } )
237
242
. then ( function ( ) {
238
243
// tag::nested-statements[]
239
244
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" } )
241
247
. subscribe ( {
242
248
onNext : function ( record ) {
243
249
session
244
250
. 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" } ) ;
246
252
} ,
247
253
onCompleted : function ( ) {
248
254
session
@@ -281,7 +287,7 @@ describe('examples', function() {
281
287
it ( 'should be able to profile' , function ( done ) {
282
288
var session = sessionGlobal ;
283
289
284
- session . run ( "CREATE (:Person {name:'Arthur'})" ) . then ( function ( ) {
290
+ session . run ( "CREATE (:Person {name: {name}})" , { name : "Arthur" } ) . then ( function ( ) {
285
291
// tag::result-summary-query-profile[]
286
292
session
287
293
. run ( "PROFILE MATCH (p:Person {name: {name}}) RETURN id(p)" , { name : "Arthur" } )
@@ -323,7 +329,7 @@ describe('examples', function() {
323
329
324
330
// tag::transaction-commit[]
325
331
var tx = session . beginTransaction ( ) ;
326
- tx . run ( "CREATE (:Person {name: 'Guinevere'})" ) ;
332
+ tx . run ( "CREATE (:Person {name: {name}})" , { name : "Guinevere" } ) ;
327
333
tx . commit ( ) ;
328
334
// end::transaction-commit[]
329
335
} ) ;
@@ -333,7 +339,7 @@ describe('examples', function() {
333
339
334
340
// tag::transaction-rollback[]
335
341
var tx = session . beginTransaction ( ) ;
336
- tx . run ( "CREATE (:Person {name: 'Merlin'})" ) ;
342
+ tx . run ( "CREATE (:Person {name: {name}})" , { name : "Merlin" } ) ;
337
343
tx . rollback ( ) ;
338
344
// end::transaction-rollback[]
339
345
} ) ;
0 commit comments