method Table.update
Updates the row with the primary key of x; a missing row panics (Db.tryUpdate returns a DbError).
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:")!
db.Item.insert(Item{ id: 1, name: "tea", price: 3 })
db.Item.update(Item{ id: 1, name: "tea", price: 5 })
print("{db.Item.all()[0].price}")
db.close()
}Вывод
5
pub(api) fn update(x: &T) dbС версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
x | &T |
Эффекты
db
Определено в: std/orm/orm.oxl:1089