Clears all where expressions from the query.
db.selectFrom('person')
.selectAll()
.where('id','=',42)
.clearWhere()
The generated SQL(PostgreSQL):
select * from "person"
Specify a single column as the conflict target.
Also see the columns, constraint and expression methods for alternative ways to specify the conflict target.
Specify a list of columns as the conflict target.
Also see the column, constraint and expression methods for alternative ways to specify the conflict target.
Specify a specific constraint by name as the conflict target.
Also see the column, columns and expression methods for alternative ways to specify the conflict target.
Adds the "do nothing" conflict action.
await db
.insertInto('person')
.values({ first_name, pic })
.onConflict((oc) => oc
.column('pic')
.doNothing()
)
The generated SQL (PostgreSQL):
insert into "person" ("first_name", "pic")
values ($1, $2)
on conflict ("pic") do nothing
Adds the "do update set" conflict action.
await db
.insertInto('person')
.values({ first_name, pic })
.onConflict((oc) => oc
.column('pic')
.doUpdateSet({ first_name })
)
The generated SQL (PostgreSQL):
insert into "person" ("first_name", "pic")
values ($1, $2)
on conflict ("pic")
do update set "first_name" = $3
In the next example we use the ref
method to reference
columns of the virtual table excluded
in a type-safe way
to create an upsert operation:
db.insertInto('person')
.values(person)
.onConflict((oc) => oc
.column('id')
.doUpdateSet((eb) => ({
first_name: eb.ref('excluded.first_name'),
last_name: eb.ref('excluded.last_name')
}))
)
Specify an expression as the conflict target.
This can be used if the unique index is an expression index.
Also see the column, columns and constraint methods for alternative ways to specify the conflict target.
Specify an index predicate for the index target.
See where for more info.
Specify an index predicate for the index target.
See whereRef for more info.
Generated using TypeDoc
Simply calls the provided function passing
this
as the only argument.$call
returns what the provided function returns.