OxL Reference

method Db.tryDelete

Deletes the row with the primary key of x.

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.tryDelete(Item{ id: 1, name: "ghost", price: 1 }) {
    DbError e => print("{e.kind == DbErrorKind.NotFound}")
    _ => print("deleted")
  }
  db.close()
}
Output
true
pub(api) fn tryDelete<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:452

See also