Class MergeQueryBuilder<DB, TT, O>

Type Parameters

  • DB

  • TT extends keyof DB

  • O

Hierarchy

  • MergeQueryBuilder

Constructors

Methods

Constructors

Methods

  • Changes a merge into query to an merge top into query.

    top clause is only supported by some dialects like MS SQL Server.

    Examples

    Affect 5 matched rows at most:

    await db.mergeInto('person')
    .top(5)
    .using('pet', 'person.id', 'pet.owner_id')
    .whenMatched()
    .thenDelete()
    .execute()

    The generated SQL (MS SQL Server):

    merge top(5) into "person"
    using "pet" on "person"."id" = "pet"."owner_id"
    when matched then
    delete

    Affect 50% of matched rows:

    await db.mergeInto('person')
    .top(50, 'percent')
    .using('pet', 'person.id', 'pet.owner_id')
    .whenMatched()
    .thenDelete()
    .execute()

    The generated SQL (MS SQL Server):

    merge top(50) percent into "person"
    using "pet" on "person"."id" = "pet"."owner_id"
    when matched then
    delete

    Parameters

    • expression: number | bigint
    • Optional modifiers: "percent"

    Returns MergeQueryBuilder<DB, TT, O>

Generated using TypeDoc