OxL Справочник OxL
РусскийEnglish

method Db.tryUpdate

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

Example:

oxl✓ проверяется в 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()
}
Вывод
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

См. также