3

I am trying to update a specific column on a list of rows in MySql using Exposed.

Actually Exposed supports a batchInsert, but there is nothing similar to a batchUpdate, is there any workaround for this?

NOTE: the table is not an IdTable.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291

1 Answers1

1

There are BatchUpdateStatement which works with IdTables.

val yourData = listOf<DataToUpdate>()
BatchUpdateStatement(FooTable).apply {
    yourData.forEach {
        addBatch(it.id)
        this[FooTable.name] = it.name
        this[FooTable.column] = it.field
    }
    execute(Transaction.current())
}
Tapac
  • 1,889
  • 1
  • 14
  • 18