Support querying by tags

This commit is contained in:
Alex Gleason 2023-08-08 23:40:08 -05:00
parent 6c96240602
commit b408838ae0
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 9 additions and 0 deletions

View File

@ -58,6 +58,15 @@ async function getFilter<K extends number = number>(filter: Filter<K>): Promise<
query = query.limit(filter.limit!);
break;
}
if (key.startsWith('#')) {
const tag = key.replace(/^#/, '');
const value = filter[key as `#${string}`] as string[];
query = query
.leftJoin('tags', 'tags.event_id', 'events.id')
.where('tags.tag', '=', tag)
.where('tags.value_1', 'in', value);
}
}
const events = await query.execute();