Files
yellowjacket/backend/database/sql/sqlcgen/libraries.sql.go
T
yonlu 02548dd55e feat(10-02): add sqlc queries for libraries and update playlist queries for phantom support
- 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
2026-03-09 09:47:30 -04:00

131 lines
2.8 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: libraries.sql
package sqlcgen
import (
"context"
)
const countLibraries = `-- name: CountLibraries :one
SELECT COUNT(*) AS count FROM libraries
`
func (q *Queries) CountLibraries(ctx context.Context) (int64, error) {
row := q.db.QueryRowContext(ctx, countLibraries)
var count int64
err := row.Scan(&count)
return count, err
}
const createLibrary = `-- name: CreateLibrary :one
INSERT INTO libraries (name, path) VALUES (?, ?)
RETURNING id, name, path, created_at
`
type CreateLibraryParams struct {
Name string
Path string
}
func (q *Queries) CreateLibrary(ctx context.Context, arg CreateLibraryParams) (Library, error) {
row := q.db.QueryRowContext(ctx, createLibrary, arg.Name, arg.Path)
var i Library
err := row.Scan(
&i.ID,
&i.Name,
&i.Path,
&i.CreatedAt,
)
return i, err
}
const deleteLibrary = `-- name: DeleteLibrary :exec
DELETE FROM libraries WHERE id = ?
`
func (q *Queries) DeleteLibrary(ctx context.Context, id int64) error {
_, err := q.db.ExecContext(ctx, deleteLibrary, id)
return err
}
const getAllLibraries = `-- name: GetAllLibraries :many
SELECT id, name, path, created_at FROM libraries ORDER BY name
`
func (q *Queries) GetAllLibraries(ctx context.Context) ([]Library, error) {
rows, err := q.db.QueryContext(ctx, getAllLibraries)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Library
for rows.Next() {
var i Library
if err := rows.Scan(
&i.ID,
&i.Name,
&i.Path,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getLibrary = `-- name: GetLibrary :one
SELECT id, name, path, created_at FROM libraries WHERE id = ? LIMIT 1
`
func (q *Queries) GetLibrary(ctx context.Context, id int64) (Library, error) {
row := q.db.QueryRowContext(ctx, getLibrary, id)
var i Library
err := row.Scan(
&i.ID,
&i.Name,
&i.Path,
&i.CreatedAt,
)
return i, err
}
const getLibraryByPath = `-- name: GetLibraryByPath :one
SELECT id, name, path, created_at FROM libraries WHERE path = ? LIMIT 1
`
func (q *Queries) GetLibraryByPath(ctx context.Context, path string) (Library, error) {
row := q.db.QueryRowContext(ctx, getLibraryByPath, path)
var i Library
err := row.Scan(
&i.ID,
&i.Name,
&i.Path,
&i.CreatedAt,
)
return i, err
}
const updateLibraryName = `-- name: UpdateLibraryName :exec
UPDATE libraries SET name = ? WHERE id = ?
`
type UpdateLibraryNameParams struct {
Name string
ID int64
}
func (q *Queries) UpdateLibraryName(ctx context.Context, arg UpdateLibraryNameParams) error {
_, err := q.db.ExecContext(ctx, updateLibraryName, arg.Name, arg.ID)
return err
}