insert Or Update
fun <T : Table> T.insertOrUpdate(vararg keys: Column<*>, body: T.(InsertStatement<Number>) -> Unit): InsertOrUpdate<Number>(source)
Inserts or updates on conflict with keys.
Usage - pollId and userId is composite primary key, intention is to insert new pollOption or update current one.
Votes.insertOrUpdate(Votes.pollId, Votes.userId) {
it[pollId] = pollAction.pollId
it[pollOption] = pollAction.optionId
it[userId] = pollAction.userId
}
Content copied to clipboard