graph-tx
v1.0.1
Published
Isolated Transactions for the graph-core graph
Downloads
4
Readme
graph-tx
Isolated Transactions for the graph-core graph
Usage
const createTransaction = require('graph-tx');
const g = require('./graph');
const tx = createTransaction.bind(null, g);
tx(({ graph, commit }) => {
graph.setVertex(...);
commit(); // mark tx as done
});
tx(({ graph }) => {
graph.setVertex(...);
// auto commit on successful termination of transaction
});
tx(({ graph, rollback }) => {
graph.setVertex(...);
rollback(); // rollback changes and mark as done
});
tx(({ graph }) => {
graph.setVertex(...);
throw new Error(); // auto rollback on errors
});
tx(({ graph, commit, rollback }) => {
// do stuff
}, {
onCommit() {
// do stuff after commit
},
onRollback(err) {
// do stuff after rollback
}
});