• Start

Methods

transaction_multi

The transaction_multi() method for the SurrealDB Mojo SDK runs a list of statements as one atomic transaction.

Wraps a list of statements in BEGIN TRANSACTION; and COMMIT TRANSACTION; and sends them as a single atomic query. This works on any transport and is the recommended way to run a transaction over HTTP.

Method Syntax
client.transaction_multi(statements, session)

Argument

Description

statements

The statements to run, as a

List[String]

. A trailing semicolon is added to each if missing.

session

An optional session id.

from std.collections import List

var stmts = List[String]()
stmts.append("CREATE car:a SET wheels = 4;")
stmts.append("CREATE car:b SET wheels = 4;")
var resp = client.transaction_multi(stmts)

If any statement fails, the whole transaction is rolled back.

Was this page helpful?