Skip to content

Commit a70e280

Browse files
committed
addressing some comments
1 parent 573b645 commit a70e280

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

README.md

+20-18
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var neo4j = require('neo4j-driver')
4444
import 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
5050
driver.close() // returns a Promise
@@ -103,7 +103,7 @@ import neo4j from 'https://cdn.jsdelivr.net/npm/[email protected]/lib/browser/n
103103
```
104104

105105
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
107107
is 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.
120120
var 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.
127127
await 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+
//
298299
var 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

328329
var 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

packages/neo4j-driver/README.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var neo4j = require('neo4j-driver')
4444
import 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
5050
driver.close() // returns a Promise
@@ -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
@@ -345,7 +345,7 @@ implicitTxResultPromise
345345
.catch(error => {
346346
console.log(error)
347347
})
348-
.then(() => session.close())
348+
.finally(() => session.close())
349349
```
350350

351351
### Explicit Transactions
@@ -431,9 +431,11 @@ rxSession
431431

432432
```javascript
433433
// Run a Cypher statement, reading the result in a streaming manner as records arrive:
434-
driver
435-
.executeQuery('MERGE (alice:Person {name : $nameParam}) RETURN alice.name AS name', {
436-
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+
})
437439
})
438440
.subscribe({
439441
onKeys: keys => {
@@ -473,7 +475,6 @@ driver
473475
.catch(error => {
474476
console.log(error)
475477
})
476-
.then(() => session.close())
477478
```
478479

479480
#### Consuming Records with Reactive API

0 commit comments

Comments
 (0)