Starts a session-scoped transaction and returns a handle. The handle buffers statements and flushes them on commit().
Method Syntax
client.begin_transaction(session)Arguments
Argument | Description |
|---|---|
session | An optional session id. |
Handle methods
The returned handle exposes:
query(query, bindings_json)to buffer a statement.create(thing, content_json)andselect(thing)convenience wrappers.commit()to run the buffered statements atomically.cancel()to discard them.
Example usage
var txn = client.begin_transaction()
_ = txn.query("CREATE person:alice SET age = 30;")
_ = txn.query("CREATE person:bob SET age = 31;")
txn.commit()Note
Session transactions run over a stateful WebSocket session. WebSocket support is rolling out. For atomic transactions over HTTP, use transaction_multi().