method Db.tryDelete
Deletes the row with the primary key of x.
Example:
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 dbSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
x | &T |
Returns
()
Errors
DbError@error- `DbError` (`NotFound` when there is no such row).
Effects
db
Defined in: std/orm/orm.oxl:452