@@ -37,7 +37,7 @@ describe('examples', function() {
37
37
jasmine . DEFAULT_TIMEOUT_INTERVAL = 10000 ;
38
38
39
39
//tag::construct-driver[]
40
- var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
40
+ var driver = neo4j . driver ( "bolt://localhost:7687 " , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
41
41
//end::construct-driver[]
42
42
driverGlobal = driver ;
43
43
} ) ;
@@ -68,13 +68,14 @@ describe('examples', function() {
68
68
var neo4j = require ( 'neo4j-driver' ) . v1 ;
69
69
// end::minimal-example-import[]
70
70
// tag::minimal-example[]
71
- var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
71
+ var driver = neo4j . driver ( "bolt://localhost:7687 " , neo4j . auth . basic ( "neo4j" , "neo4j" ) ) ;
72
72
var session = driver . session ( ) ;
73
73
session
74
- . run ( "CREATE (a:Person {name:'Arthur' , title:'King'})" )
74
+ . run ( "CREATE (a:Person {name: {name} , title: {title}})" , { name : "Arthur" , title : "King" } )
75
75
. then ( function ( )
76
76
{
77
- return session . run ( "MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title" )
77
+ return session . run ( "MATCH (a:Person) WHERE a.name = {name} RETURN a.name AS name, a.title AS title" ,
78
+ { name : "Arthur" } )
78
79
} )
79
80
. then ( function ( result ) {
80
81
console . log ( result . records [ 0 ] . get ( "title" ) + " " + result . records [ 0 ] . get ( "name" ) ) ;
@@ -91,11 +92,11 @@ describe('examples', function() {
91
92
it ( 'should be able to configure session pool size' , function ( done ) {
92
93
var neo4j = neo4jv1 ;
93
94
// tag::configuration[]
94
- var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) , { connectionPoolSize : 50 } ) ;
95
+ var driver = neo4j . driver ( "bolt://localhost:7687 " , neo4j . auth . basic ( "neo4j" , "neo4j" ) , { connectionPoolSize : 50 } ) ;
95
96
//end::configuration[]
96
97
97
98
var s = driver . session ( ) ;
98
- s . run ( "CREATE (p:Person { name: {name} })" , { name : "The One" } )
99
+ s . run ( "CREATE (p:Person {name: {name}})" , { name : "The One" } )
99
100
. then ( function ( result ) {
100
101
var theOnesCreated = result . summary . counters . nodesCreated ( ) ;
101
102
console . log ( theOnesCreated ) ;
@@ -129,7 +130,7 @@ describe('examples', function() {
129
130
var session = driverGlobal . session ( ) ;
130
131
// tag::statement-without-parameters[]
131
132
session
132
- . run ( "CREATE (p:Person { name: 'Arthur' })" )
133
+ . run ( "CREATE (p:Person {name: 'Arthur'})" )
133
134
// end::statement-without-parameters[]
134
135
. then ( function ( result ) {
135
136
var theOnesCreated = result . summary . counters . nodesCreated ( ) ;
@@ -147,12 +148,12 @@ describe('examples', function() {
147
148
it ( 'should be able to iterate results' , function ( done ) {
148
149
var session = driverGlobal . session ( ) ;
149
150
session
150
- . run ( "CREATE (weapon:Weapon { name: ' Sword in the stone' })" )
151
+ . run ( "CREATE (weapon:Weapon {name: { name}})" , { name : " Sword in the stone" } )
151
152
. then ( function ( ) {
152
153
// tag::result-traversal[]
153
154
var searchTerm = "Sword" ;
154
155
session
155
- . run ( "MATCH (weapon:Weapon) WHERE weapon.name CONTAINS {term} RETURN weapon.name" , { term : searchTerm } )
156
+ . run ( "MATCH (weapon:Weapon) WHERE weapon.name CONTAINS {term} RETURN weapon.name" , { term : searchTerm } )
156
157
. subscribe ( {
157
158
onNext : function ( record ) {
158
159
console . log ( "" + record . get ( "weapon.name" ) ) ;
@@ -176,12 +177,14 @@ describe('examples', function() {
176
177
it ( 'should be able to access records' , function ( done ) {
177
178
var session = driverGlobal . session ( ) ;
178
179
session
179
- . run ( "CREATE (weapon:Weapon { name: 'Sword in the stone', owner: 'Arthur', material: 'Stone', size: 'Huge' })" )
180
+ . run ( "CREATE (weapon:Weapon {name: {name}, owner: {owner}, material: {material}, size: {size}})" ,
181
+ { name : "Sword in the stone" , owner : "Arthur" , material : "Stone" , size : "Huge" } )
180
182
. then ( function ( ) {
181
183
// tag::access-record[]
182
184
var searchTerm = "Arthur" ;
183
185
session
184
- . run ( "MATCH (weapon:Weapon) WHERE weapon.owner CONTAINS {term} RETURN weapon.name, weapon.material, weapon.size" , { term : searchTerm } )
186
+ . run ( "MATCH (weapon:Weapon) WHERE weapon.owner CONTAINS {term} RETURN weapon.name, weapon.material, weapon.size" ,
187
+ { term : searchTerm } )
185
188
. subscribe ( {
186
189
onNext : function ( record ) {
187
190
var sword = [ ] ;
@@ -212,11 +215,12 @@ describe('examples', function() {
212
215
var session = driverGlobal . session ( ) ;
213
216
214
217
session
215
- . run ( "CREATE (knight:Person:Knight { name: ' Lancelot' , castle: ' Camelot' })" )
218
+ . run ( "CREATE (knight:Person:Knight {name: { name}, castle: {castle}})" , { name : " Lancelot" , castle : " Camelot" } )
216
219
. then ( function ( ) {
217
220
// tag::retain-result[]
218
221
session
219
- . run ( "MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN knight.name AS name" , { castle : "Camelot" } )
222
+ . run ( "MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN knight.name AS name" ,
223
+ { castle : "Camelot" } )
220
224
. then ( function ( result ) {
221
225
var records = [ ] ;
222
226
for ( var i = 0 ; i < result . records . length ; i ++ ) {
@@ -244,17 +248,19 @@ describe('examples', function() {
244
248
it ( 'should be able to do nested queries' , function ( done ) {
245
249
var session = driverGlobal . session ( ) ; ;
246
250
session
247
- . run ( "CREATE (knight:Person:Knight { name: 'Lancelot', castle: 'Camelot' })" +
248
- "CREATE (king:Person { name: 'Arthur', title: 'King' })" )
251
+ . run ( "CREATE (knight:Person:Knight {name: {name1}, castle: {castle}})" +
252
+ "CREATE (king:Person {name: {name2}, title: {title}})" ,
253
+ { name1 : "Lancelot" , castle : "Camelot" , name2 : "Arthur" , title : "King" } )
249
254
. then ( function ( ) {
250
255
// tag::nested-statements[]
251
256
session
252
- . run ( "MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN id(knight) AS knight_id" , { "castle" : "Camelot" } )
257
+ . run ( "MATCH (knight:Person:Knight) WHERE knight.castle = {castle} RETURN id(knight) AS knight_id" ,
258
+ { castle : "Camelot" } )
253
259
. subscribe ( {
254
260
onNext : function ( record ) {
255
261
session
256
262
. run ( "MATCH (knight) WHERE id(knight) = {id} MATCH (king:Person) WHERE king.name = {king} CREATE (knight)-[:DEFENDS]->(king)" ,
257
- { "id" : record . get ( "knight_id" ) , " king" : "Arthur" } ) ;
263
+ { id : record . get ( "knight_id" ) , king : "Arthur" } ) ;
258
264
} ,
259
265
onCompleted : function ( ) {
260
266
session
@@ -295,7 +301,7 @@ describe('examples', function() {
295
301
it ( 'should be able to profile' , function ( done ) {
296
302
var session = driverGlobal . session ( ) ;
297
303
298
- session . run ( "CREATE (:Person {name:'Arthur'})" ) . then ( function ( ) {
304
+ session . run ( "CREATE (:Person {name: {name}})" , { name : "Arthur" } ) . then ( function ( ) {
299
305
// tag::result-summary-query-profile[]
300
306
session
301
307
. run ( "PROFILE MATCH (p:Person {name: {name}}) RETURN id(p)" , { name : "Arthur" } )
@@ -340,7 +346,7 @@ describe('examples', function() {
340
346
341
347
// tag::transaction-commit[]
342
348
var tx = session . beginTransaction ( ) ;
343
- tx . run ( "CREATE (:Person {name: 'Guinevere'})" ) ;
349
+ tx . run ( "CREATE (:Person {name: {name}})" , { name : "Guinevere" } ) ;
344
350
tx . commit ( ) . then ( function ( ) { session . close ( ) } ) ;
345
351
// end::transaction-commit[]
346
352
} ) ;
@@ -350,15 +356,15 @@ describe('examples', function() {
350
356
351
357
// tag::transaction-rollback[]
352
358
var tx = session . beginTransaction ( ) ;
353
- tx . run ( "CREATE (:Person {name: 'Merlin'})" ) ;
359
+ tx . run ( "CREATE (:Person {name: {name}})" , { name : "Merlin" } ) ;
354
360
tx . rollback ( ) . then ( function ( ) { session . close ( ) } ) ;
355
361
// end::transaction-rollback[]
356
362
} ) ;
357
363
358
364
it ( 'should document how to require encryption' , function ( ) {
359
365
var neo4j = neo4jv1 ;
360
366
// tag::tls-require-encryption[]
361
- var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
367
+ var driver = neo4j . driver ( "bolt://localhost:7687 " , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
362
368
//In NodeJS, encryption is ENCRYPTION_NON_LOCAL on by default. In the web bundle, it is ENCRYPTION_OFF.
363
369
encrypted :"ENCRYPTION_ON"
364
370
} ) ;
@@ -369,7 +375,7 @@ describe('examples', function() {
369
375
it ( 'should document how to configure trust-on-first-use' , function ( ) {
370
376
var neo4j = neo4jv1 ;
371
377
// tag::tls-trust-on-first-use[]
372
- var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
378
+ var driver = neo4j . driver ( "bolt://localhost:7687 " , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
373
379
// Note that trust-on-first-use is not available in the browser bundle,
374
380
// in NodeJS, trust-on-first-use is the default trust mode. In the browser
375
381
// it is TRUST_CUSTOM_CA_SIGNED_CERTIFICATES.
@@ -383,7 +389,7 @@ describe('examples', function() {
383
389
it ( 'should document how to configure a trusted signing certificate' , function ( ) {
384
390
var neo4j = neo4jv1 ;
385
391
// tag::tls-signed[]
386
- var driver = neo4j . driver ( "bolt://localhost" , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
392
+ var driver = neo4j . driver ( "bolt://localhost:7687 " , neo4j . auth . basic ( "neo4j" , "neo4j" ) , {
387
393
trust : "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES" ,
388
394
// Configuring which certificates to trust here is only available
389
395
// in NodeJS. In the browser bundle the browsers list of trusted
@@ -398,7 +404,7 @@ describe('examples', function() {
398
404
it ( 'should document how to disable auth' , function ( ) {
399
405
var neo4j = neo4jv1 ;
400
406
// tag::connect-with-auth-disabled[]
401
- var driver = neo4j . driver ( "bolt://localhost" , {
407
+ var driver = neo4j . driver ( "bolt://localhost:7687 " , {
402
408
// In NodeJS, encryption is on by default. In the web bundle, it is off.
403
409
encrypted :"ENCRYPTION_NON_LOCAL"
404
410
} ) ;
0 commit comments