feat(db): add paged + count queries for library reads

This commit is contained in:
2026-04-21 00:01:15 -04:00
parent 62e48642e2
commit fb49a39492
6 changed files with 136 additions and 0 deletions
+11
View File
@@ -11,6 +11,17 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
const countAlbumsMatching = `-- name: CountAlbumsMatching :one
SELECT COUNT(*) FROM albums WHERE title ILIKE '%' || $1::text || '%'
`
func (q *Queries) CountAlbumsMatching(ctx context.Context, dollar_1 string) (int64, error) {
row := q.db.QueryRow(ctx, countAlbumsMatching, dollar_1)
var count int64
err := row.Scan(&count)
return count, err
}
const getAlbumByArtistAndTitle = `-- name: GetAlbumByArtistAndTitle :one
SELECT id, title, sort_title, artist_id, release_date, mbid, cover_art_path, created_at, updated_at FROM albums WHERE artist_id = $1 AND title = $2 LIMIT 1
`