Refactor EventStore to use a more Set-like interface

This commit is contained in:
Alex Gleason
2024-01-08 15:13:10 -06:00
parent f8a0698c3a
commit 937ae1eab6
28 changed files with 111 additions and 111 deletions

View File

@@ -63,7 +63,7 @@ function connectStream(socket: WebSocket) {
async function handleReq([_, subId, ...rest]: ClientREQ): Promise<void> {
const filters = prepareFilters(rest);
for (const event of await eventsDB.getEvents(filters, { limit: FILTER_LIMIT })) {
for (const event of await eventsDB.filter(filters, { limit: FILTER_LIMIT })) {
send(['EVENT', subId, event]);
}
@@ -96,7 +96,7 @@ function connectStream(socket: WebSocket) {
/** Handle COUNT. Return the number of events matching the filters. */
async function handleCount([_, subId, ...rest]: ClientCOUNT): Promise<void> {
const count = await eventsDB.countEvents(prepareFilters(rest));
const count = await eventsDB.count(prepareFilters(rest));
send(['COUNT', subId, { count, approximate: false }]);
}