EventsDB: fix the tag queries bug, DVM: remove unnecessary conditional
This commit is contained in:
parent
29a63f262f
commit
0fde577149
|
@ -7,10 +7,6 @@ import { eventsDB } from '@/storages.ts';
|
||||||
|
|
||||||
export class DVM {
|
export class DVM {
|
||||||
static async event(event: NostrEvent): Promise<void> {
|
static async event(event: NostrEvent): Promise<void> {
|
||||||
if (event.kind < 5000 || event.kind > 5999) {
|
|
||||||
throw new Error('Unsupported event kind');
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (event.kind) {
|
switch (event.kind) {
|
||||||
case 5950:
|
case 5950:
|
||||||
await DVM.nameRegistration(event);
|
await DVM.nameRegistration(event);
|
||||||
|
|
|
@ -181,13 +181,15 @@ class EventsDB implements NStore {
|
||||||
query = query.limit(filter.limit!);
|
query = query.limit(filter.limit!);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (key.startsWith('#')) {
|
const joinedQuery = query.leftJoin('tags', 'tags.event_id', 'events.id');
|
||||||
const tag = key.replace(/^#/, '');
|
|
||||||
const value = filter[key as `#${string}`] as string[];
|
for (const [key, value] of Object.entries(filter)) {
|
||||||
query = query
|
if (key.startsWith('#') && Array.isArray(value)) {
|
||||||
.leftJoin('tags', 'tags.event_id', 'events.id')
|
const name = key.replace(/^#/, '');
|
||||||
.where('tags.tag', '=', tag)
|
query = joinedQuery
|
||||||
|
.where('tags.tag', '=', name)
|
||||||
.where('tags.value', 'in', value);
|
.where('tags.value', 'in', value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue