Generates an atomic INSERT or UPDATE (upsert) action if supported.
Generates an atomic INSERT or UPDATE (upsert) action if supported.
- conflict target
- update statement, declared as function: (table, excluded) => (assign, result)
table
- is used to extract column for update assignment and reference existing row
excluded
- aliases excluded table, e.g. row proposed for insertion.
assign
- left hand side of assignment. Should be accessed from table
argument
result
- right hand side of assignment.
Example usage:
insert.onConflictUpdate(_.id)((t, e) => t.col -> (e.col + t.col))
If insert statement violates conflict target then the column col
of row will be updated with sum of
existing value and and proposed col
in insert.