Module

x/kysely_postgrs_js_dialect/deps.ts>kysely.QueryCreator#replaceInto

Kysely dialect for PostgreSQL using the Postgres.js client.
method kysely.QueryCreator.prototype.replaceInto
import { kysely } from "https://dotland.deno.dev/x/kysely_postgrs_js_dialect@v0.27.3/deps.ts";
const { QueryCreator } = kysely;

Creates a replace query.

A MySQL-only statement similar to {@link InsertQueryBuilder.onDuplicateKeyUpdate} that deletes and inserts values on collision instead of updating existing rows.

The return value of this query is an instance of InsertResult. InsertResult has the {@link InsertResult.insertId | insertId} field that holds the auto incremented id of the inserted row if the db returned one.

See the {@link InsertQueryBuilder.values | values} method for more info and examples.

Examples

const result = await db
  .replaceInto('person')
  .values({
    first_name: 'Jennifer',
    last_name: 'Aniston'
  })
  .executeTakeFirst()

console.log(result.insertId)

Type Parameters

T extends keyof DB & string