Add initial database setup and user/artist management functionality
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.30.0
|
||||
// source: albums.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getAlbumByID = `-- name: GetAlbumByID :one
|
||||
SELECT id, name, artist, release_date, album_art_url FROM albums WHERE id = $1
|
||||
`
|
||||
|
||||
// albums.sql
|
||||
func (q *Queries) GetAlbumByID(ctx context.Context, id pgtype.UUID) (Album, error) {
|
||||
row := q.db.QueryRow(ctx, getAlbumByID, id)
|
||||
var i Album
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Artist,
|
||||
&i.ReleaseDate,
|
||||
&i.AlbumArtUrl,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAllAlbums = `-- name: GetAllAlbums :many
|
||||
SELECT id, name, artist, release_date, album_art_url FROM albums
|
||||
`
|
||||
|
||||
func (q *Queries) GetAllAlbums(ctx context.Context) ([]Album, error) {
|
||||
rows, err := q.db.Query(ctx, getAllAlbums)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Album
|
||||
for rows.Next() {
|
||||
var i Album
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Name,
|
||||
&i.Artist,
|
||||
&i.ReleaseDate,
|
||||
&i.AlbumArtUrl,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
Reference in New Issue
Block a user