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)}")
}Output
b 1
pub(api) fn upsert<T>(x: &T) dbSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
x | &T |
Effects
db
Defined in: std/orm/orm.oxl:372