?
db.upsert
Insert or update on a declared unique constraint using SQLite ON CONFLICT.
Table.upsert(conflictKey, data) → T
Inserts a row, or updates the existing one when it collides on a declared unique constraint, using SQLite's ON CONFLICT. The conflict key you pass must match a unique constraint declared on the table or it throws, and on conflict every non-conflict column is overwritten with the incoming values. Use it for idempotent writes keyed by something stable like an email or an external id, where a plain db.push would fail on the second call.
Parameters
conflictKey
string | string[]
RequiredA declared unique column or column group.
data
Partial<T>
RequiredRow to insert or merge.
Upsert
await Users.upsert('email', { email, name, role: 'member' });