Anybody using Spring R2bc with Kotlin. I am just w...
# server
n
Anybody using Spring R2bc with Kotlin. I am just wondering how to use DB transaction using coroutine.
☝️ 1
r
i'm using such helper function:
Copy code
suspend fun <T> tx(connectionFactory: ConnectionFactory, block: () -> Mono<T>): T {
    val tm = R2dbcTransactionManager(connectionFactory)
    val operator = TransactionalOperator.create(tm)
    return block().`as`<Mono<T>>(operator::transactional).awaitSingle()
}
as a block you can pass a chain of standard reactive calls joined with
then
or
flatMap
s
Depending on your DB server maybe this might help. https://github.com/JetBrains/Exposed
m
Exposed doesn't support R2DBC yet: https://github.com/JetBrains/Exposed/issues/456
🤔 1