Module

x/kysely_postgrs_js_dialect/mod.ts>kysely.WheneableMergeQueryBuilder#whenMatched

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

Adds a simple when matched clause to the query.

For a when matched clause with an and condition, see {@link whenMatchedAnd}.

For a simple when not matched clause, see {@link whenNotMatched}.

For a when not matched clause with an and condition, see {@link whenNotMatchedAnd}.

Examples

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

The generated SQL (PostgreSQL):

merge into "person"
using "pet" on "person"."id" = "pet"."owner_id"
when matched then
  delete