Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/kysely_postgrs_js_dialect/mod.ts>kysely.NotMatchedThenableMergeQueryBuilder

Kysely dialect for PostgreSQL using the Postgres.js client.
Latest
class kysely.NotMatchedThenableMergeQueryBuilder
import { kysely } from "https://deno.land/x/kysely_postgrs_js_dialect@v0.27.4/mod.ts";
const { NotMatchedThenableMergeQueryBuilder } = kysely;

Constructors

new
NotMatchedThenableMergeQueryBuilder(props: MergeQueryBuilderProps)

Type Parameters

DB
TT extends keyof DB
ST extends keyof DB
O

Methods

Performs the do nothing action.

This is supported in PostgreSQL.

To perform the insert action, see thenInsertValues.

Examples

const result = await db.mergeInto('person')
  .using('pet', 'person.id', 'pet.owner_id')
  .whenNotMatched()
  .thenDoNothing()
  .execute()

The generated SQL (PostgreSQL):

merge into "person"
using "pet" on "person"."id" = "pet"."owner_id"
when not matched then
  do nothing
thenInsertValues<I extends InsertObjectOrList<DB, TT>>(insert: I): WheneableMergeQueryBuilder<DB, TT, ST, O>

Performs the insert (...) values action.

This method is similar to InsertQueryBuilder.values, so see the documentation for that method for more examples.

To perform the do nothing action, see thenDoNothing.

Examples

const result = await db.mergeInto('person')
  .using('pet', 'person.id', 'pet.owner_id')
  .whenNotMatched()
  .thenInsertValues({
    first_name: 'John',
    last_name: 'Doe',
  })
  .execute()

The generated SQL (PostgreSQL):

merge into "person"
using "pet" on "person"."id" = "pet"."owner_id"
when not matched then
  insert ("first_name", "last_name") values ($1, $2)
thenInsertValues<IO extends InsertObjectOrListFactory<DB, TT, ST>>(insert: IO): WheneableMergeQueryBuilder<DB, TT, ST, O>