feat(db): add paged + count queries for library reads
This commit is contained in:
@@ -24,3 +24,16 @@ SELECT * FROM artists
|
||||
WHERE name ILIKE '%' || $1 || '%'
|
||||
ORDER BY sort_name
|
||||
LIMIT $2 OFFSET $3;
|
||||
|
||||
-- name: ListArtistsAlpha :many
|
||||
SELECT * FROM artists ORDER BY sort_name, name, id LIMIT $1 OFFSET $2;
|
||||
|
||||
-- name: ListArtistsNewest :many
|
||||
-- Secondary id tiebreaker keeps pagination stable when created_at ties.
|
||||
SELECT * FROM artists ORDER BY created_at DESC, id DESC LIMIT $1 OFFSET $2;
|
||||
|
||||
-- name: CountArtists :one
|
||||
SELECT COUNT(*) FROM artists;
|
||||
|
||||
-- name: CountArtistsMatching :one
|
||||
SELECT COUNT(*) FROM artists WHERE name ILIKE '%' || $1::text || '%';
|
||||
|
||||
Reference in New Issue
Block a user