@@ -44,7 +44,7 @@ var neo4j = require('neo4j-driver')
4444import neo4j from ' neo4j-driver'
4545```
4646
47- Driver instance should be closed when Node.js application exits:
47+ Driver instance should be closed when the application exits:
4848
4949``` javascript
5050driver .close () // returns a Promise
@@ -103,7 +103,7 @@ import neo4j from 'https://cdn.jsdelivr.net/npm/neo4j-driver@X.Y.Z/lib/browser/n
103103```
104104
105105It 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
107107is not the same as the lifetime of the web page:
108108
109109``` javascript
@@ -116,13 +116,13 @@ driver.close() // returns a Promise
116116
117117``` javascript
118118// 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.
120120var driver = neo4j .driver (
121121 ' neo4j://localhost' ,
122122 neo4j .auth .basic (' neo4j' , ' password' )
123123)
124124
125- // Close the driver when the application exits.
125+ // Close the driver when application exits.
126126// This closes all used network connections.
127127await driver .close ()
128128```
@@ -226,7 +226,7 @@ readTxResultPromise
226226 .catch (error => {
227227 console .log (error)
228228 })
229- .then (() => session .close ())
229+ .finally (() => session .close ())
230230```
231231
232232#### Reading with Reactive Session
@@ -270,7 +270,7 @@ writeTxResultPromise
270270 .catch (error => {
271271 console .log (error)
272272 })
273- .then (() => session .close ())
273+ .finally (() => session .close ())
274274```
275275
276276#### Writing with Reactive Session
@@ -295,14 +295,15 @@ rxSession
295295``` javascript
296296// Since 5.8.0, the driver has offered a way to run a single query transaction with minimal boilerplate.
297297// The driver.executeQuery() function features the same automatic retries as transaction functions.
298+ //
298299var executeQueryResultPromise = driver
299300 .executeQuery (
300- " MATCH (alice:Person {name: $nameParam}) RETURN alice.DOB AS DateOfBirth" ,
301+ " MATCH (alice:Person {name: $nameParam}) RETURN alice.DOB AS DateOfBirth" ,
301302 {
302303 nameParam: ' Alice'
303- },
304+ },
304305 {
305- routing: ' READ' ,
306+ routing: ' READ' ,
306307 database: ' neo4j'
307308 }
308309 )
@@ -320,17 +321,17 @@ executeQueryResultPromise
320321### Auto-Commit/Implicit Transaction
321322
322323``` 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.
324325// The driver will not automatically retry implicit transactions.
325326// 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.
327328
328329var implicitTxResultPromise = session
329330 .run (
330- " CALL { … } IN TRANSACTIONS" ,
331+ " CALL { … } IN TRANSACTIONS" ,
331332 {
332333 param1: ' param'
333- },
334+ },
334335 {
335336 database: ' neo4j'
336337 }
@@ -344,7 +345,7 @@ implicitTxResultPromise
344345 .catch (error => {
345346 console .log (error)
346347 })
347- .then (() => session .close ())
348+ .finally (() => session .close ())
348349```
349350
350351### Explicit Transactions
@@ -430,9 +431,11 @@ rxSession
430431
431432``` javascript
432433// 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+ })
436439 })
437440 .subscribe ({
438441 onKeys : keys => {
@@ -472,7 +475,6 @@ driver
472475 .catch (error => {
473476 console .log (error)
474477 })
475- .then (() => session .close ())
476478```
477479
478480#### Consuming Records with Reactive API
0 commit comments