events-backend: fix for subscription failing if there are no events

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-05-26 21:14:02 +02:00
parent d2e733c8b6
commit 65e58b53d8
@@ -392,7 +392,9 @@ export class DatabaseEventBusStore implements EventBusStore {
id,
updated_at: this.#db.fn.now(),
topics,
read_until: this.#db<EventsRow>(TABLE_EVENTS).max('id') as any, // TODO: figure out TS,
read_until: this.#db.raw(
`( SELECT COALESCE(MAX("id"), 0) FROM "${TABLE_EVENTS}" )`,
),
})
.onConflict('id')
.merge(['topics', 'updated_at'])