OxL Reference

data Db

Handle of an open database (std.orm, §12.8): Db.open("sqlite:shop.db"). Methods: std/orm/orm.oxl.

Example:

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

@table("notes")
data Note {
  @pk id: i64
  text: str
}

fn main() -> () | DbError io, db {
  let db = Db.open("sqlite::memory:")?
  db.insert(Note{ id: 1, text: "hello" })
  print("{db.Note.count()}")
}
Output
1
@derive(Copy)
pub(api) data Db

Thread safety. a handle that may be shared by tasks; transactions (`atomic`) belong to one task.

Since. 1.0.0-beta

Fields

pub(api) h: i64

Handle of the connection in the runtime.

Defined in: std/core/types.oxl:225

See also