import { kysely } from "https://deno.land/x/kysely_postgrs_js_dialect@v0.27.4/deps.ts";
const { WheneableMergeQueryBuilder } = kysely;
Adds a simple when not matched
clause to the query.
For a when not matched
clause with an and
condition, see whenNotMatchedAnd.
For a simple when matched
clause, see whenMatched.
For a when matched
clause with an and
condition, see whenMatchedAnd.
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)
Returns
NotMatchedThenableMergeQueryBuilder<DB, TT, ST, O>