feat(db): add GetBooksByTag query for tag detail page

Uses $2 = ANY(tags) to match against the tags text[] column with GIN
index support. sqlc generates a single string Column2 param (not []string).
This commit is contained in:
2026-05-10 16:11:46 -04:00
parent 0acacc1aa0
commit 647dec676f
3 changed files with 98 additions and 0 deletions
+5
View File
@@ -2167,3 +2167,8 @@ SELECT
FROM libraries l
JOIN library_types lt ON l.library_type_id = lt.id
WHERE l.id = $1;
-- name: GetBooksByTag :many
SELECT * FROM media_items
WHERE library_id = $1 AND tags @> ARRAY[$2::text]
ORDER BY title ASC;