Module

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

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

Adds the when matched clause to the query with an and condition.

This method is similar to {@link SelectQueryBuilder.where}, so see the documentation for that method for more examples.

For a simple when matched clause (without an and condition) see {@link whenMatched}.

Examples

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

The generated SQL (PostgreSQL):

merge into "person"
using "pet" on "person"."id" = "pet"."owner_id"
when matched and "person"."first_name" = $1 then
  delete

Type Parameters

RE extends ReferenceExpression<DB, TT | ST>
VE extends OperandValueExpressionOrList<DB, TT | ST, RE>

Parameters

expression: E