@@ -44,7 +44,7 @@ var neo4j = require('neo4j-driver')
44
44
import neo4j from ' neo4j-driver'
45
45
```
46
46
47
- Driver instance should be closed when Node.js application exits:
47
+ Driver instance should be closed when the application exits:
48
48
49
49
``` javascript
50
50
driver .close () // returns a Promise
@@ -103,7 +103,7 @@ import neo4j from 'https://cdn.jsdelivr.net/npm/
[email protected] /lib/browser/n
103
103
```
104
104
105
105
It is not required to explicitly close the driver on a web page. Web browser should gracefully close all open
106
- WebSockets when the page is unloaded. However, driver instance should be explicitly closed when its lifetime
106
+ WebSockets when the page is unloaded. However, driver instance should be explicitly closed when it's lifetime
107
107
is not the same as the lifetime of the web page:
108
108
109
109
``` javascript
@@ -116,13 +116,13 @@ driver.close() // returns a Promise
116
116
117
117
``` javascript
118
118
// Create a driver instance, for the user `neo4j` with password `password`.
119
- // It should be enough to have a single driver per DBMS per application.
119
+ // It should be enough to have a single driver per database per application.
120
120
var driver = neo4j .driver (
121
121
' neo4j://localhost' ,
122
122
neo4j .auth .basic (' neo4j' , ' password' )
123
123
)
124
124
125
- // Close the driver when the application exits.
125
+ // Close the driver when application exits.
126
126
// This closes all used network connections.
127
127
await driver .close ()
128
128
```
@@ -226,7 +226,7 @@ readTxResultPromise
226
226
.catch (error => {
227
227
console .log (error)
228
228
})
229
- .then (() => session .close ())
229
+ .finally (() => session .close ())
230
230
```
231
231
232
232
#### Reading with Reactive Session
@@ -270,7 +270,7 @@ writeTxResultPromise
270
270
.catch (error => {
271
271
console .log (error)
272
272
})
273
- .then (() => session .close ())
273
+ .finally (() => session .close ())
274
274
```
275
275
276
276
#### Writing with Reactive Session
@@ -295,14 +295,15 @@ rxSession
295
295
``` javascript
296
296
// Since 5.8.0, the driver has offered a way to run a single query transaction with minimal boilerplate.
297
297
// The driver.executeQuery() function features the same automatic retries as transaction functions.
298
+ //
298
299
var executeQueryResultPromise = driver
299
300
.executeQuery (
300
- " MATCH (alice:Person {name: $nameParam}) RETURN alice.DOB AS DateOfBirth" ,
301
+ " MATCH (alice:Person {name: $nameParam}) RETURN alice.DOB AS DateOfBirth" ,
301
302
{
302
303
nameParam: ' Alice'
303
- },
304
+ },
304
305
{
305
- routing: ' READ' ,
306
+ routing: ' READ' ,
306
307
database: ' neo4j'
307
308
}
308
309
)
@@ -320,17 +321,17 @@ executeQueryResultPromise
320
321
### Auto-Commit/Implicit Transaction
321
322
322
323
``` javascript
323
- // This is the most basic and limited form with which to run a Cypher query.
324
+ // This is the most basic and limited form with which to run a Cypher query.
324
325
// The driver will not automatically retry implicit transactions.
325
326
// This function should only be used when the other driver query interfaces do not fit the purpose.
326
- // Implicit transactions are the only ones that can be used for CALL { … } IN TRANSACTIONS queries.
327
+ // Implicit transactions are the only ones that can be used for CALL { … } IN TRANSACTIONS queries.
327
328
328
329
var implicitTxResultPromise = session
329
330
.run (
330
- " CALL { … } IN TRANSACTIONS" ,
331
+ " CALL { … } IN TRANSACTIONS" ,
331
332
{
332
333
param1: ' param'
333
- },
334
+ },
334
335
{
335
336
database: ' neo4j'
336
337
}
@@ -344,7 +345,7 @@ implicitTxResultPromise
344
345
.catch (error => {
345
346
console .log (error)
346
347
})
347
- .then (() => session .close ())
348
+ .finally (() => session .close ())
348
349
```
349
350
350
351
### Explicit Transactions
@@ -430,9 +431,11 @@ rxSession
430
431
431
432
``` javascript
432
433
// Run a Cypher statement, reading the result in a streaming manner as records arrive:
433
- driver
434
- .executeQuery (' MERGE (alice:Person {name : $nameParam}) RETURN alice.name AS name' , {
435
- nameParam: ' Alice'
434
+ session
435
+ .executeWrite (tx => {
436
+ return tx .run (' MERGE (alice:Person {name : $nameParam}) RETURN alice.name AS name' , {
437
+ nameParam: ' Alice'
438
+ })
436
439
})
437
440
.subscribe ({
438
441
onKeys : keys => {
@@ -472,7 +475,6 @@ driver
472
475
.catch (error => {
473
476
console .log (error)
474
477
})
475
- .then (() => session .close ())
476
478
```
477
479
478
480
#### Consuming Records with Reactive API
0 commit comments