Ofek Teken
05/24/2024, 12:07 PMgenerateAsync
with SQLDelight with a PostgreSQL database. But I can't seem to find docs on how to create the R2BCDriver. Up until now I had HikariCP with .asJdbcDriver()
extension.
My main problem comes down to doing a transaction over multiple "DAOs" If have aDAO
& bDAO
and they both expose suspend functions such as:
suspend someQuery() = withContext(<http://Dispatchers.IO|Dispatchers.IO>) { queries.bla() }
I now want to create a transaction in a place where I inject both DAOs to perform a job, and make sure both functions are under a transaction. The problem is that Dataabase.transaction's lambda block doesn't support suspending calls..
What's the recommended approach? Thanks!Ofek Teken
06/04/2024, 9:52 PMhfhbd
06/04/2024, 10:00 PMhfhbd
06/04/2024, 10:12 PMOfek Teken
06/05/2024, 3:37 PMaDAO
& bDAO
and they both expose suspend functions such as:
suspend someQuery() = withContext(<http://Dispatchers.IO|Dispatchers.IO>) { queries.bla() }
And I want to use them under one class which injects both and execute them both under a single transaction, e.g.:
class Something(val aDao: ADao, val bDao: BDao) {
fun invoke() {
transaction {
aDao.something()
bDao.something()
}
}
}
To get the transaction lambda I can simply inject a Transacter and use it - the problem as I've stated, I cannot use suspending functions within the current lambdahfhbd
06/05/2024, 4:47 PM