Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

MatchedThenableMergeQueryBuilder

class MatchedThenableMergeQueryBuilder<DB, TT extends keyof DB, ST extends keyof DB, UT extends TT | ST, O> {
constructor(props: MergeQueryBuilderProps);
thenDelete(): WheneableMergeQueryBuilder<DB, TT, ST, O>;
thenDoNothing(): WheneableMergeQueryBuilder<DB, TT, ST, O>;
thenUpdate<QB extends UpdateQueryBuilder<DB, TT, UT, never>>(set: (ub: QB) => QB): WheneableMergeQueryBuilder<DB, TT, ST, O>;
thenUpdateSet<UO extends UpdateObject<DB, UT, TT>>(update: UO): WheneableMergeQueryBuilder<DB, TT, ST, O>;
thenUpdateSet<U extends UpdateObjectFactory<DB, UT, TT>>(update: U): WheneableMergeQueryBuilder<DB, TT, ST, O>;
thenUpdateSet<RE extends ReferenceExpression<DB, TT>, VE extends ValueExpression<DB, UT, ExtractUpdateTypeFromReferenceExpression<DB, TT, RE>>>(key: RE, value: VE): WheneableMergeQueryBuilder<DB, TT, ST, O>;
}

§Type Parameters

§
TT extends keyof DB
[src]
§
ST extends keyof DB
[src]
§
UT extends TT | ST
[src]

§Constructors

§
new MatchedThenableMergeQueryBuilder(props: MergeQueryBuilderProps)
[src]

§Methods

§
thenDelete(): WheneableMergeQueryBuilder<DB, TT, ST, O>
[src]

Performs the delete action.

To perform the do nothing action, see {@link thenDoNothing}.

To perform the update action, see {@link thenUpdate} or {@link thenUpdateSet}.

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
§
thenDoNothing(): WheneableMergeQueryBuilder<DB, TT, ST, O>
[src]

Performs the do nothing action.

This is supported in PostgreSQL.

To perform the delete action, see {@link thenDelete}.

To perform the update action, see {@link thenUpdate} or {@link thenUpdateSet}.

Examples

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

The generated SQL (PostgreSQL):

merge into "person"
using "pet" on "person"."id" = "pet"."owner_id"
when matched then
  do nothing
§
thenUpdate<QB extends UpdateQueryBuilder<DB, TT, UT, never>>(set: (ub: QB) => QB): WheneableMergeQueryBuilder<DB, TT, ST, O>
[src]

Perform an update operation with a full-fledged UpdateQueryBuilder. This is handy when multiple set invocations are needed.

For a shorthand version of this method, see {@link thenUpdateSet}.

To perform the delete action, see {@link thenDelete}.

To perform the do nothing action, see {@link thenDoNothing}.

Examples

import { sql } from 'kysely'

const result = await db.mergeInto('person')
  .using('pet', 'person.id', 'pet.owner_id')
  .whenMatched()
  .thenUpdate((ub) => ub
    .set(sql`metadata['has_pets']`, 'Y')
    .set({
      updated_at: Date.now(),
    })
  )
  .execute()

The generated SQL (PostgreSQL):

merge into "person"
using "pet" on "person"."id" = "pet"."owner_id"
when matched then
  update set metadata['has_pets'] = $1, "updated_at" = $2
§
thenUpdateSet<UO extends UpdateObject<DB, UT, TT>>(update: UO): WheneableMergeQueryBuilder<DB, TT, ST, O>
[src]

Performs an update set action, similar to UpdateQueryBuilder.set.

For a full-fledged update query builder, see {@link thenUpdate}.

To perform the delete action, see {@link thenDelete}.

To perform the do nothing action, see {@link thenDoNothing}.

Examples

const result = await db.mergeInto('person')
  .using('pet', 'person.id', 'pet.owner_id')
  .whenMatched()
  .thenUpdateSet({
    middle_name: 'dog owner',
  })
  .execute()

The generate SQL (PostgreSQL):

merge into "person"
using "pet" on "person"."id" = "pet"."owner_id"
when matched then
  update set "middle_name" = $1
thenUpdateSet<U extends UpdateObjectFactory<DB, UT, TT>>(update: U): WheneableMergeQueryBuilder<DB, TT, ST, O>
[src]
thenUpdateSet<RE extends ReferenceExpression<DB, TT>, VE extends ValueExpression<DB, UT, ExtractUpdateTypeFromReferenceExpression<DB, TT, RE>>>(key: RE, value: VE): WheneableMergeQueryBuilder<DB, TT, ST, O>
[src]