method Db.tryUpdate
Replaces all columns of the row with this primary key; NotFound / panic if there is none.
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.tryUpdate(Item{ id: 1, name: "ghost", price: 1 }) {
DbError e => print("{e.kind == DbErrorKind.NotFound}")
_ => print("updated")
}
db.close()
}Вывод
true
pub(api) fn tryUpdate<T>(x: &T) -> () | DbError dbС версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
x | &T |
Возвращает
()
Ошибки
DbError@error- `DbError` (`NotFound` when there is no such row).
Эффекты
db
Определено в: std/orm/orm.oxl:402