OxL Reference

method Table.update

Updates the row with the primary key of x; a missing row panics (Db.tryUpdate returns a DbError).

Example:

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

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

fn main() io, db {
  let db = Db.open("sqlite::memory:")!
  db.Item.insert(Item{ id: 1, name: "tea", price: 3 })
  db.Item.update(Item{ id: 1, name: "tea", price: 5 })
  print("{db.Item.all()[0].price}")
  db.close()
}
Output
5
pub(api) fn update(x: &T) db

Since. 1.0.0-beta

Parameters

NameType
x&T

Effects

db

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

See also