Skip to content

Commit f81efd3

Browse files
authored
Update README.md
Multiple transactions example
1 parent 8fb84d2 commit f81efd3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ Explicit transactions API:
161161
```javascript
162162
// run statement in a transaction
163163
var tx = session.beginTransaction();
164+
164165
tx.run("MERGE (bob:Person {name : {nameParam} }) RETURN bob.name AS name", {nameParam: 'Bob'})
165166
.subscribe({
166167
onNext: function (record) {
@@ -173,6 +174,19 @@ tx.run("MERGE (bob:Person {name : {nameParam} }) RETURN bob.name AS name", {name
173174
console.log(error);
174175
}
175176
});
177+
178+
tx.run("MERGE (adam:Person {name : {nameParam} }) RETURN adam.name AS name", {nameParam: 'Adam'})
179+
.subscribe({
180+
onNext: function (record) {
181+
console.log(record.get('name'));
182+
},
183+
onCompleted: function () {
184+
session.close();
185+
},
186+
onError: function (error) {
187+
console.log(error);
188+
}
189+
});
176190

177191
//decide if the transaction should be committed or rolled back
178192
var success = false;

0 commit comments

Comments
 (0)