Using the neo4jrb/neo4j gem (8.x), I know it is possible to run multiple queries inside a single transaction like so
person = Person.find_by(id: person_id)
Neo4j::ActiveBase.run_transaction do |tx|
person.update(name: 'New name')
person.update(number: 1)
end
But it possible to open a transaction, and then use that same transaction across multiple blocks. Something like:
person = Person.find_by(id: person_id)
transaction = Neo4j::ActiveBase.new_transaction
transaction.run do |tx|
person.update(name: 'New name')
end
transaction.run do |tx|
person.update(number: 1)
end
transaction.close
The reason why this functionality is desirable is because I'm using Neo4jrb inside of a Trailblazer-Operation. The trailblazer operation is broken up into discrete steps which are themselves written as separate methods. I want several of the steps wrapped in a transaction, but, without monkey patching the operation, I don't have the ability to execute some steps inside one transaction block.
Thanks!