https://kotlinlang.org logo
#exposed
Title
# exposed
a

Ali Albaali

05/13/2021, 5:43 PM
Is there a way to return a
Flow
from a query?
j

Joost Klitsie

05/14/2021, 8:35 AM
Copy code
flow {
    transaction {
    //...
    }
}
I mean you can wrap the query into something that returns a flow
A query itself is a one-time event that works fine with just using a suspend function
a

Ali Albaali

05/14/2021, 8:42 AM
I think I phrased it wrong. What I meant is to emit new data whenever the database table gets updated.
j

Joost Klitsie

05/14/2021, 8:44 AM
That is indeed a very different thing 🙂 I do not think it comes out of the box
Perhaps you can check how it works on the database you are using, like postgresql has listen/notify
perhaps someone already made a library (quick google https://github.com/Benjozork/exposed-postgres-extensions ) to help with that
and then you can wrap the results in a flow or whatever
a

Ali Albaali

05/14/2021, 10:32 AM
Yeah I thought there was a solution out of the box. Thank you for your help! 😃
2 Views