retrieval by #p tag

This commit is contained in:
Martti Malmi 2023-08-18 19:08:47 +03:00
parent b6a70a0085
commit 2f494ed437
2 changed files with 6 additions and 8 deletions

View File

@ -1,5 +1,5 @@
import loki from 'lokijs';
import { Event, matchFilter } from 'nostr-tools';
import { Event } from 'nostr-tools';
import Filter from '@/nostr/Filter.ts';
import { ID, STR } from '@/utils/UniqueIds.ts';
@ -66,7 +66,9 @@ class EventDB {
}
const clone = this.pack(event);
const flatTags = clone.tags.filter((tag) => tag[0] === 'e').map((tag) => tag.join('_'));
const flatTags = clone.tags
.filter((tag) => ['e', 'p'].includes(tag[0]))
.map((tag) => tag.join('_'));
try {
this.eventsCollection.insert({ ...clone, flatTags });
@ -106,10 +108,8 @@ class EventDB {
if (filter['#e']) {
// hmm $contains doesn't seem to use binary indexes
query.flatTags = { $contains: 'e_' + filter['#e'].map(ID) };
}
if (filter['#p']) {
// not indexing for now
//query.flatTags = { $contains: 'p_' + filter['#p'].map(ID) };
} else if (filter['#p']) {
query.flatTags = { $contains: 'p_' + filter['#p'].map(ID) };
}
if (filter.since && filter.until) {
query.created_at = { $between: [filter.since, filter.until] };

View File

@ -27,8 +27,6 @@ export class MyDexie extends Dexie {
}
}
const INITIAL_EVENT_LOAD_LIMIT = 5000;
const db = new MyDexie();
const handleEvent = (event: Event & { id: string }) => {