Transasction wrapper for Node2Neo queries Transactions allow the creation of multiple Node2Neo transactions. Transactions store cypher statements in case of an error and store events to be triggered once the transaction has been successfully committed.
Transactions are useful when you have multiple separate items to create but want an "all-or-nothing" commital approach in the database. For example event nodes are a good way of tracking changes to a node over time. Every change that is created you create a new event node and link it via a relationship to the updated node. In this instance you have to update the original node, create a new event node, create a relationship between teh two, update other existing relationships and potentially more. Transactions are useful in this and other use cases.
var db = ''var Transaction = ;var trans1 = db;trans1
[statement] is optional and can be a cypher string or an object with 'statement' and 'parameters' properties. See the node2neo-model repository for transaction options.
After opening a transasction you can execute a number of statements on the transaction. These will all run and return an error or the results of the transaction. You can nest transactions, if you need the previous new node id, for example.
Using the async library is useful for running multiple items in sync or parallel.
Once all of the transactions have been applied you can commit the transaction to the database.
After you have opened a transaction and have applied all of the statements you can commit the transaction.
Transactions automatically expire after a period of time. If you want to remove a transaction before this time you can explicitly remove it.