Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oakfang/graph-tx
Isolated Transactions for the graph-core graph
https://github.com/oakfang/graph-tx
Last synced: 20 days ago
JSON representation
Isolated Transactions for the graph-core graph
- Host: GitHub
- URL: https://github.com/oakfang/graph-tx
- Owner: oakfang
- License: mit
- Created: 2019-02-15T12:36:44.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-15T23:43:51.000Z (almost 6 years ago)
- Last Synced: 2024-12-10T05:46:34.026Z (about 2 months ago)
- Language: JavaScript
- Size: 47.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graph-tx
Isolated Transactions for the @xgraph/core graph
## Usage
```js
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
}
});
```