io.github.dehuckakpyt.telegrambot.ext.transaction.TransactionExt.kt Maven / Gradle / Ivy
The newest version!
package io.github.dehuckakpyt.telegrambot.ext.transaction
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.jetbrains.exposed.sql.transactions.transaction
import java.sql.Connection
/**
* Created on 05.05.2024.
*
* @author Denis Matytsin
*/
suspend inline fun readQuery(crossinline block: () -> T): T = withContext(Dispatchers.IO) {
transaction(Connection.TRANSACTION_READ_COMMITTED, readOnly = true) {
block()
}
}
suspend inline fun executeQuery(crossinline block: () -> T): T = withContext(Dispatchers.IO) {
transaction(Connection.TRANSACTION_READ_COMMITTED, readOnly = false) {
block()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy