Execute suspending function in jdbi's "inTransaction" handle
I'm currently working on a kotlin project and for the database layer I'm using jdbi (instead of an ORM I want to use something where I can write plain SQL).
I have to execute multiple statements in a transaction and the statements are already packed in suspending functions. To run multiple statements in one transaction I try to use the following code:
suspend fun withinTransaction(fn: suspend (Handle) -> T): T =
jdbi.inTransaction { handle ->
fn(handle)
}
This is...