OxL Reference

method Db.tryUpdate

Replaces all columns of the row with this primary key; NotFound / panic if there is none.

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:")!
  match db.tryUpdate(Item{ id: 1, name: "ghost", price: 1 }) {
    DbError e => print("{e.kind == DbErrorKind.NotFound}")
    _ => print("updated")
  }
  db.close()
}
Output
true
pub(api) fn tryUpdate<T>(x: &T) -> () | DbError  db

Since. 1.0.0-beta

Parameters

NameType
x&T

Returns

()

Errors

  • DbError @error
  • `DbError` (`NotFound` when there is no such row).

Effects

db

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

See also