OxL Reference

method Db.begin

Starts a transaction; end it with commit or rollback (prefer transaction or atomic(db)).

Example:

oxl✓ checked in CI
use std.orm { Db }

@table("items")
data Item { @pk id: i64; name: str }

fn main() io, db {
  let db = Db.open("sqlite::memory:")!
  db.insert(Item{ id: 1, name: "a" })
  db.begin()!
  db.insert(Item{ id: 2, name: "b" })
  db.rollback()!
  print("{db.count(Item)}")
}
Output
1
pub(api) fn begin() -> () | DbError  db

Since. 1.0.0-beta

Returns

()

Errors

Effects

db

Defined in: std/orm/orm.oxl:621

See also