Skip to main content
Module

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

Kysely dialect for PostgreSQL using the Postgres.js client.
Go to Latest
method kysely.QueryCreator.prototype.replaceInto
Re-export
import { kysely } from "https://deno.land/x/kysely_postgrs_js_dialect@v0.27.3/deps.ts";
const { QueryCreator } = kysely;

Creates a replace query.

A MySQL-only statement similar to 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 InsertResult.insertId | insertId field that holds the auto incremented id of the inserted row if the db returned one.

See the 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