diff --git a/src/db/events.ts b/src/db/events.ts index bac26580..71bc7657 100644 --- a/src/db/events.ts +++ b/src/db/events.ts @@ -1,7 +1,9 @@ import { db, type TagRow } from '@/db.ts'; -import { type Filter, type Insertable } from '@/deps.ts'; +import { type Insertable } from '@/deps.ts'; import { type SignedEvent } from '@/event.ts'; +import type { DittoFilter } from '@/types.ts'; + type TagCondition = ({ event, count }: { event: SignedEvent; count: number }) => boolean; /** Conditions for when to index certain tags. */ @@ -42,19 +44,12 @@ function insertEvent(event: SignedEvent): Promise { return results; }, []); - await Promise.all(tags.map((tag) => { - return trx.insertInto('tags') - .values(tag) - .execute(); - })); + await trx.insertInto('tags') + .values(tags) + .execute(); }); } -/** Custom filter interface that extends Nostr filters with extra options for Ditto. */ -interface DittoFilter extends Filter { - local?: boolean; -} - /** Build the query for a filter. */ function getFilterQuery(filter: DittoFilter) { let query = db diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 00000000..6c7feba0 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,8 @@ +import { type Filter } from '@/deps.ts'; + +/** Custom filter interface that extends Nostr filters with extra options for Ditto. */ +interface DittoFilter extends Filter { + local?: boolean; +} + +export { type DittoFilter };