Hi! Is it possible to get transaction context insi...
# exposed
d
Hi! Is it possible to get transaction context inside other thread? I have code like this:
Copy code
transaction {
            FirstObject.selectAll()
            supplyAsync {
                runBlocking {
                    SecondObject.selectAll()
                }
            }
        }
I need to do both calls inside one transaction. When calling
SecondObject.selectAll()
, I got exception
No transaction in context
. https://github.com/JetBrains/Exposed/wiki/Transactions#working-with-coroutines -> This should probably help me, but I did not fully understand how to use it.
t
I'm not sure but maybe something like:
Copy code
transaction {
                    FirstObject.selectAll()
                    val result = async {       
                        suspendedTransaction {
                            SecondObject.selectAll().toList()
                        }
                    }
                    
                    println("${result.await()}")
                }