TableRunner.upsert() method
Home > @direct-sqlite/core > TableRunner > upsert
TableRunner.upsert() method
Section titled “TableRunner.upsert() method”Executes write assertions, running cell overrides if targeted index boundaries trigger collision states.
Signature:
upsert(data: Partial<TRow>, conflictTarget: keyof TRow, updateFields: (keyof TRow)[]): { changes: any; lastInsertRowId: number; };Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
data |
Partial<TRow> |
An object containing the columns and their values to be inserted or updated. |
|
conflictTarget |
keyof TRow |
The column name that should be used as the conflict target for the UPSERT operation. |
|
updateFields |
(keyof TRow)[] |
An array of column names that should be updated with the new values from the data object if a conflict occurs. |
Returns:
{ changes: any; lastInsertRowId: number; }
The result of the upsert operation, which typically includes the number of changes made and the last inserted or updated row ID. The exact structure of the result may depend on the underlying SQLite client being used.