OxL Справочник OxL
РусскийEnglish

data Table

A table of a database, db.User for a @table type (§12.8); from u in db.User where … is compiled to SQL (§5.9).

Example:

oxl✓ проверяется в 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" })
  db.insert(Note{ id: 2, text: "world" })
  for text in from n in db.Note where n.id > 1 select n.text {
    print(text)
  }
}
Вывод
world
@derive(Copy)
pub(api) data Table<T>

С версии. 1.0.0-beta

Поля

pub(api) db: Db

The database the table belongs to.

Определено в: std/core/types.oxl:254

См. также