- Create libraries.sql with 7 CRUD queries (create, get, get-by-path, list, update, delete, count) - Update playlists.sql: AddPlaylistTrack now accepts 9 params including phantom metadata - Update playlist queries to use LEFT JOIN for nullable audio_file_id - Add GetTrackPhantomMetadata helper query for eager phantom population - Add is_phantom computed column to metadata queries - Add GetAudioFilesByLibrary and CountAudioFilesByLibrary queries - Regenerate all sqlc code
22 lines
528 B
SQL
22 lines
528 B
SQL
-- name: CreateLibrary :one
|
|
INSERT INTO libraries (name, path) VALUES (?, ?)
|
|
RETURNING *;
|
|
|
|
-- name: GetLibrary :one
|
|
SELECT * FROM libraries WHERE id = ? LIMIT 1;
|
|
|
|
-- name: GetLibraryByPath :one
|
|
SELECT * FROM libraries WHERE path = ? LIMIT 1;
|
|
|
|
-- name: GetAllLibraries :many
|
|
SELECT * FROM libraries ORDER BY name;
|
|
|
|
-- name: UpdateLibraryName :exec
|
|
UPDATE libraries SET name = ? WHERE id = ?;
|
|
|
|
-- name: DeleteLibrary :exec
|
|
DELETE FROM libraries WHERE id = ?;
|
|
|
|
-- name: CountLibraries :one
|
|
SELECT COUNT(*) AS count FROM libraries;
|