diff --git a/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts b/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts index 9248e1c0e5..0a8dddfe51 100644 --- a/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts +++ b/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts @@ -392,7 +392,9 @@ export class DatabaseEventBusStore implements EventBusStore { id, updated_at: this.#db.fn.now(), topics, - read_until: this.#db(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'])