You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+74-74
Original file line number
Diff line number
Diff line change
@@ -188,76 +188,6 @@ var rxSession = driver.rxSession({
188
188
})
189
189
```
190
190
191
-
### Executing Queries
192
-
193
-
#### Consuming Records with Streaming API
194
-
195
-
```javascript
196
-
// Run a Cypher statement, reading the result in a streaming manner as records arrive:
197
-
session
198
-
.run('MERGE (alice:Person {name : $nameParam}) RETURN alice.name AS name', {
199
-
nameParam:'Alice'
200
-
})
201
-
.subscribe({
202
-
onKeys:keys=> {
203
-
console.log(keys)
204
-
},
205
-
onNext:record=> {
206
-
console.log(record.get('name'))
207
-
},
208
-
onCompleted: () => {
209
-
session.close() // returns a Promise
210
-
},
211
-
onError:error=> {
212
-
console.log(error)
213
-
}
214
-
})
215
-
```
216
-
217
-
Subscriber API allows following combinations of `onKeys`, `onNext`, `onCompleted` and `onError` callback invocations:
218
-
219
-
- zero or one `onKeys`,
220
-
- zero or more `onNext` followed by `onCompleted` when operation was successful. `onError` will not be invoked in this case
221
-
- zero or more `onNext` followed by `onError` when operation failed. Callback `onError` might be invoked after couple `onNext` invocations because records are streamed lazily by the database. `onCompleted` will not be invoked in this case.
222
-
223
-
#### Consuming Records with Promise API
224
-
225
-
```javascript
226
-
// the Promise way, where the complete result is collected before we act on it:
227
-
session
228
-
.run('MERGE (james:Person {name : $nameParam}) RETURN james.name AS name', {
229
-
nameParam:'James'
230
-
})
231
-
.then(result=> {
232
-
result.records.forEach(record=> {
233
-
console.log(record.get('name'))
234
-
})
235
-
})
236
-
.catch(error=> {
237
-
console.log(error)
238
-
})
239
-
.then(() =>session.close())
240
-
```
241
-
242
-
#### Consuming Records with Reactive API
243
-
244
-
```javascript
245
-
rxSession
246
-
.run('MERGE (james:Person {name: $nameParam}) RETURN james.name AS name', {
// It is possible to execute read transactions that will benefit from automatic
277
207
// retries on both single instance ('bolt' URI scheme) and Causal Cluster
278
208
// ('neo4j' URI scheme) and will get automatic load balancing in cluster deployments
279
-
var readTxResultPromise =session.readTransaction(txc=> {
209
+
var readTxResultPromise =session.executeRead(txc=> {
280
210
// used transaction will be committed automatically, no need for explicit commit/rollback
281
211
282
212
var result =txc.run('MATCH (person:Person) RETURN person.name AS name')
@@ -300,7 +230,7 @@ readTxResultPromise
300
230
301
231
```javascript
302
232
rxSession
303
-
.readTransaction(txc=>
233
+
.executeRead(txc=>
304
234
txc
305
235
.run('MATCH (person:Person) RETURN person.name AS name')
306
236
.records()
@@ -318,7 +248,7 @@ rxSession
318
248
```javascript
319
249
// It is possible to execute write transactions that will benefit from automatic retries
320
250
// on both single instance ('bolt' URI scheme) and Causal Cluster ('neo4j' URI scheme)
321
-
var writeTxResultPromise =session.writeTransaction(asynctxc=> {
251
+
var writeTxResultPromise =session.executeWrite(asynctxc=> {
322
252
// used transaction will be committed automatically, no need for explicit commit/rollback
323
253
324
254
var result =awaittxc.run(
@@ -344,7 +274,7 @@ writeTxResultPromise
344
274
345
275
```javascript
346
276
rxSession
347
-
.writeTransaction(txc=>
277
+
.executeWrite(txc=>
348
278
txc
349
279
.run("MERGE (alice:Person {name: 'James'}) RETURN alice.name AS name")
350
280
.records()
@@ -357,6 +287,76 @@ rxSession
357
287
})
358
288
```
359
289
290
+
### Consuming Records
291
+
292
+
#### Consuming Records with Streaming API
293
+
294
+
```javascript
295
+
// Run a Cypher statement, reading the result in a streaming manner as records arrive:
296
+
session
297
+
.run('MERGE (alice:Person {name : $nameParam}) RETURN alice.name AS name', {
298
+
nameParam:'Alice'
299
+
})
300
+
.subscribe({
301
+
onKeys:keys=> {
302
+
console.log(keys)
303
+
},
304
+
onNext:record=> {
305
+
console.log(record.get('name'))
306
+
},
307
+
onCompleted: () => {
308
+
session.close() // returns a Promise
309
+
},
310
+
onError:error=> {
311
+
console.log(error)
312
+
}
313
+
})
314
+
```
315
+
316
+
Subscriber API allows following combinations of `onKeys`, `onNext`, `onCompleted` and `onError` callback invocations:
317
+
318
+
- zero or one `onKeys`,
319
+
- zero or more `onNext` followed by `onCompleted` when operation was successful. `onError` will not be invoked in this case
320
+
- zero or more `onNext` followed by `onError` when operation failed. Callback `onError` might be invoked after couple `onNext` invocations because records are streamed lazily by the database. `onCompleted` will not be invoked in this case.
321
+
322
+
#### Consuming Records with Promise API
323
+
324
+
```javascript
325
+
// the Promise way, where the complete result is collected before we act on it:
326
+
session
327
+
.run('MERGE (james:Person {name : $nameParam}) RETURN james.name AS name', {
328
+
nameParam:'James'
329
+
})
330
+
.then(result=> {
331
+
result.records.forEach(record=> {
332
+
console.log(record.get('name'))
333
+
})
334
+
})
335
+
.catch(error=> {
336
+
console.log(error)
337
+
})
338
+
.then(() =>session.close())
339
+
```
340
+
341
+
#### Consuming Records with Reactive API
342
+
343
+
```javascript
344
+
rxSession
345
+
.run('MERGE (james:Person {name: $nameParam}) RETURN james.name AS name', {
0 commit comments