-- albums.sql
-- name: GetAlbumByID :one
SELECT * FROM albums WHERE id = $1;

-- name: GetAllAlbums :many
SELECT * FROM albums;

-- name: CreateAlbum :one
INSERT INTO albums (id, name, artist, release_date, album_art_url) VALUES ($1, $2, $3, $4, $5) RETURNING id;

-- name: UpdateAlbum :exec
UPDATE albums SET name = $2, artist = $3, release_date = $4, album_art_url = $5 WHERE id = $1;

-- name: DeleteAlbum :exec
DELETE FROM albums WHERE id = $1;

-- name: SearchAlbums :many
SELECT * FROM albums WHERE name ILIKE '%' || $1 || '%' OR artist ILIKE '%' || $1 || '%';

-- name: GetAlbumsByArtist :many
SELECT * FROM albums WHERE artist = $1;