Do we have any system in exposed (planned) that ca...
# exposed
j
Do we have any system in exposed (planned) that can transform a query into a flow, where the database emits updates automatically, like we can do in room? Even if it just emulates a change notification system by listening to update commands to make it work on single instance situations which wouldn't require any database support for this feature would be appreciated. My situation is, that I love to have my web aplications update their view in realtime when the data changes over a websocket. This could look like this:
Copy code
// Websocket handler

launch {
    db.query {
        Messages.selectAll().realtimeQuery().collect { send(it) }
    }
}
o
@Julius Babies Thank you for mentioning such a case. Have you tried r2dbc support in Exposed? It allows to execute queries as Flows. But depending on your expectations it could or couldn't fit you requirements. For example, if you expect, that such a query will live for a long time and emit new entries on every insert, it most probably will not work. For jdbc it could be tricky. As far as I know jdbc does't allow you to listen any events from database in asynchronous way, so any implementation over it will live with all restrictions of jdbc (for example it could require to hold thread and connection until the end of such 'flow') Could you give some details on what is you case? Which mechanisms of database or driver you expect to utilize?
a
Hi @Julius Babies @Oleg Babichev. I have thought about something like this too: being able to subscribe to data change notification for a table. One way I'm thinking this could be implemented is emitting an event whenever an insert, update or delete operation happens on a table. Then one can subscribe to those changes, filter for table type (if the event is emitted regardless of which table) and then do something in response.