Skip to main content
Module

x/kysely_deno_postgres_dialect/mod.ts>kysely.InsertQueryBuilder#onDuplicateKeyUpdate

Kysely dialect for PostgreSQL using the deno-postgres client.
Latest
method kysely.InsertQueryBuilder.prototype.onDuplicateKeyUpdate
Re-export
import { kysely } from "https://deno.land/x/kysely_deno_postgres_dialect@v0.27.1/mod.ts";
const { InsertQueryBuilder } = kysely;

Adds on duplicate key update to the query.

If you specify on duplicate key update, and a row is inserted that would cause a duplicate value in a unique index or primary key, an update of the old row occurs.

This is only implemented by some dialects like MySQL. On most dialects you should use onConflict instead.

Examples

await db
  .insertInto('person')
  .values(values)
  .onDuplicateKeyUpdate({ species: 'hamster' })

Parameters

update: UpdateObjectExpression<DB, TB, TB>