diff --git a/src/db/events.ts b/src/db/events.ts index 2f29189..15e24f4 100644 --- a/src/db/events.ts +++ b/src/db/events.ts @@ -106,11 +106,10 @@ function getFilterQuery(filter: DittoFilter) { /** Get events for filters from the database. */ async function getFilters(filters: DittoFilter[]): Promise[]> { - const queries = filters + const events = await filters .map(getFilterQuery) - .map((query) => query.execute()); - - const events = (await Promise.all(queries)).flat(); + .reduce((acc, curr) => acc.union(curr)) + .execute(); return events.map((event) => ( { ...event, tags: JSON.parse(event.tags) } as SignedEvent