M1/#292: album queries (upsert/get/list-by-artist)

This commit is contained in:
2026-04-19 02:31:31 +00:00
parent 7c46d8358f
commit 58b29cc4bd
+18
View File
@@ -0,0 +1,18 @@
-- name: UpsertAlbum :one
INSERT INTO albums (title, sort_title, artist_id, release_date, mbid, cover_art_path)
VALUES ($1, $2, $3, $4, $5, $6)
ON CONFLICT (mbid) WHERE mbid IS NOT NULL
DO UPDATE SET
title = EXCLUDED.title,
sort_title = EXCLUDED.sort_title,
artist_id = EXCLUDED.artist_id,
release_date = EXCLUDED.release_date,
cover_art_path = EXCLUDED.cover_art_path,
updated_at = now()
RETURNING *;
-- name: GetAlbumByID :one
SELECT * FROM albums WHERE id = $1;
-- name: ListAlbumsByArtist :many
SELECT * FROM albums WHERE artist_id = $1 ORDER BY release_date NULLS LAST, sort_title;