method Db.upsert
Inserts the row or replaces the row with the same primary key.
Example:
use std.orm { Db }
@table("items")
data Item { @pk id: i64; name: str }
fn main() io, db {
let db = Db.open("sqlite::memory:")!
db.upsert(Item{ id: 1, name: "a" })
db.upsert(Item{ id: 1, name: "b" })
print("{db.find(Item, 1)!.name} {db.count(Item)}")
}Вывод
b 1
pub(api) fn upsert<T>(x: &T) dbС версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
x | &T |
Эффекты
db
Определено в: std/orm/orm.oxl:372