OxL Reference

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✓ checked in 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>

Since. 1.0.0-beta

Fields

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.

Methods

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

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

See also