English | 简体中文

api-docs / org.ktorm.global / insert

insert

fun <T : BaseTable<*>> T.insert(
    block: AssignmentsBuilder.(T) -> Unit
): Int
(source code)

Deprecated: ktorm-global will be removed in the future, please migrate to the standard API.

Construct an insert expression in the given closure, then execute it and return the effected row count.

Usage:

Employees.insert {
set(it.name, "jerry")
set(it.job, "trainee")
set(it.managerId, 1)
set(it.hireDate, LocalDate.now())
set(it.salary, 50)
set(it.departmentId, 1)
}

Parameters

block - the DSL block, an extension function of AssignmentsBuilder, used to construct the expression.

Return
the effected row count.