Optional
modifiers: "percent"Adds the using
clause to the query.
This method is similar to innerJoin, so see the documentation for that method for more 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
Generated using TypeDoc
Changes a
merge into
query to anmerge top into
query.top
clause is only supported by some dialects like MS SQL Server.Examples
Affect 5 matched rows at most:
The generated SQL (MS SQL Server):
Affect 50% of matched rows:
The generated SQL (MS SQL Server):