Skip to content

Commit 23f2d17

Browse files
committed
Fix explicit transactions API example
Only close session after transaction is committed.
1 parent a558fcf commit 23f2d17

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ tx.run("MERGE (bob:Person {name : {nameParam} }) RETURN bob.name AS name", {name
181181
console.log(record.get('name'));
182182
},
183183
onCompleted: function () {
184-
session.close();
184+
console.log('First query completed');
185185
},
186186
onError: function (error) {
187187
console.log(error);
@@ -194,7 +194,7 @@ tx.run("MERGE (adam:Person {name : {nameParam} }) RETURN adam.name AS name", {na
194194
console.log(record.get('name'));
195195
},
196196
onCompleted: function () {
197-
session.close();
197+
console.log('Second query completed');
198198
},
199199
onError: function (error) {
200200
console.log(error);
@@ -208,7 +208,8 @@ if (success) {
208208
tx.commit()
209209
.subscribe({
210210
onCompleted: function () {
211-
// this transaction is now committed
211+
// this transaction is now committed and session can be closed
212+
session.close();
212213
},
213214
onError: function (error) {
214215
console.log(error);

0 commit comments

Comments
 (0)