DbSetup-kotlin / com.ninja_squad.dbsetup_kotlin / com.ninja_squad.dbsetup.operation.Insert.Builder / mappedValues

mappedValues

fun Builder.mappedValues(vararg entries: Pair<String, Any?>): Builder

Extension function of InsertBuilder allowing to specify values as columns/value pairs instead of a Map.

Example usage:

insertInto("user") {
    columns("id", "name", "birthDate")
    mappedValues("id" to 1, "name" to "John Doe")
}

This is equivalent to

insertInto("user") {
    columns("id", "name", "birthDate")
    values(mapOf("id" to 1, "name" to "John Doe"))
}

but is a bit shorter. Beware to NOT use

insertInto("user") {
    columns("id", "name", "birthDate")
    values("id" to 1, "name" to "John Doe")
}

because that would try to insert the Pairs themselves into the table, rather than the values of the pairs.



Parameters

entries - the column/value pairs of the row to insert

Return
the Insert Builder for chaining (although that is usually not necessary with the Kotlin DSL)

Author
JB Nizet