mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-18 22:14:23 +01:00
Refactor EventStore to use a more Set-like interface
This commit is contained in:
@@ -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 }]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user