InsertQueryBuilder
Builder for constructing INSERT queries with type-safe value insertion.Type Parameters
DB- The database schema typeTB- The table name being inserted intoO- The output type (InsertResult or custom with returning)
Methods
values
Generated or ColumnType.
Examples:
Insert a single row:
columns
values method sets both columns and values. Use this method when using expression to insert from a select query.
Example:
expression
defaultValues
insert into "person" default values query.
Example:
returning
returningAll
returning * clause to the query.
Example:
onConflict
onDuplicateKeyUpdate
ignore
insert into query to an insert ignore into query (MySQL) or insert or ignore into (SQLite).
Example:
orIgnore
insert into query to an insert or ignore into query (SQLite).
orReplace
insert into query to an insert or replace into query (SQLite).
orAbort
insert into query to an insert or abort into query (SQLite).
orFail
insert into query to an insert or fail into query (SQLite).
orRollback
insert into query to an insert or rollback into query (SQLite).
top
insert into query to an insert top into query (MS SQL Server).
Example:
output
outputAll
output inserted.* clause (MS SQL Server).
$call
this as the only argument.
Example:
$if
func(this) if condition is true.
Especially handy with optional returning or returningAll calls.
Example:
$castTo
$narrowType
execute
executeTakeFirst
undefined.