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

data Ref

Relation to one row of the table T (§12.8, D-4780): the field is a column that holds the primary key of T (an i64 key), so where o.customer.id == 7 is SQL. loaded is empty until the query asks for load(customer); then it holds the row. The type is written ref<Customer> (an alias: a lower-case generic cannot start a literal), a value Ref<Customer>{ id: 7 }.

Example:

oxl✓ проверяется в CI
use std.orm { Ref, Many, ref, many }

@table("users")
data User {
  @pk id: i64
  name: str
}

@table("orders")
data Order {
  @pk id: i64
  owner: ref<User>
}
@repr(i64)
pub(api) data Ref<T>

С версии. 1.0.0-beta

Поля

pub(api) id: i64

The primary key of the referenced row.

pub(api) loaded: List<T> = []

The referenced row, when load(..) fetched it; empty otherwise.

Методы

isLoaded() -> bool
Was the row loaded by load(..)?

Определено в: std/orm/orm.oxl:88

См. также