While I was looking over the documentation for transactions I came accross on this example:
var tx = session.beginTransaction();
tx.run("MERGE (bob:Person {name : {nameParam} }) RETURN bob.name AS name", {nameParam: 'Bob'})
.subscribe({
onNext: function (record) {
console.log(record.get('name'));
},
onCompleted: function () {
session.close();
},
onError: function (error) {
console.log(error);
}
});
//decide if the transaction should be committed or rolled back
var success = false;
if (success) {
tx.commit()
.subscribe({
onCompleted: function () {
// this transaction is now committed
},
onError: function (error) {
console.log(error);
}
});
} else {
//transaction is rolled black and nothing is created in the database
console.log('rolled back');
tx.rollback();
}
But on snippet above it does not seem to change the success
somehow I mean how it does determine whetherthe transaction sucessfully executed or not the success
variable does not change the value at all.