OxL Reference

method Db.lastInsertId

Row id of the last insert (the key an @auto row got).

Example:

oxl✓ checked in CI
use std.orm { Db }

@table("items")
data Item { @pk @auto id: i64; name: str }

fn main() io, db {
  let db = Db.open("sqlite::memory:")!
  db.insert(Item{ id: 0, name: "a" })
  print("{db.lastInsertId()}")
}
Output
1
pub(api) fn lastInsertId() -> i64  db

Since. 1.0.0-beta

Returns

i64

Effects

db

Defined in: std/orm/orm.oxl:599

See also