values

Add a VALUES (...), (...) clause, binding every element as a parameter.

client.sql {
+"INSERT INTO users (username, email)"
values(listOf(
listOf("user1", "user1@example.com"),
listOf("user2", "user2@example.com"),
))
}

Parameters

input

rows of values; each child list corresponds to one row

Throws

if input is empty, a child list is empty, or the child lists do not all have the same size


fun <T> SqlBuilder.values(input: List<T>, transformer: (T) -> List<Any?>)(source)

Add a VALUES (...), (...) clause, converting each element of input into a row using transformer.

client.sql {
+"INSERT INTO users (username, email)"
values(users) { listOf(it.username, it.email) }
}

Parameters

input

objects to insert; each element corresponds to one row

transformer

converts an element into the list of values for its row

Throws

if input is empty, transformer returns an empty list, or the returned lists do not all have the same size