regenerate sqlc

This commit is contained in:
zardzul
2026-03-14 18:18:59 +01:00
parent 433c7b4085
commit 131aee8638
6 changed files with 432 additions and 15 deletions
+62
View File
@@ -36,6 +36,15 @@ func (q *Queries) CreateArtist(ctx context.Context, arg CreateArtistParams) (pgt
return id, err
}
const deleteArtist = `-- name: DeleteArtist :exec
DELETE FROM artists WHERE id = $1
`
func (q *Queries) DeleteArtist(ctx context.Context, id pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteArtist, id)
return err
}
const getAllArtists = `-- name: GetAllArtists :many
SELECT id, name, genre, bio, artist_image_url FROM artists
`
@@ -83,3 +92,56 @@ func (q *Queries) GetArtistByID(ctx context.Context, id pgtype.UUID) (Artist, er
)
return i, err
}
const searchArtists = `-- name: SearchArtists :many
SELECT id, name, genre, bio, artist_image_url FROM artists WHERE name ILIKE '%' || $1 || '%' OR genre ILIKE '%' || $1 || '%'
`
func (q *Queries) SearchArtists(ctx context.Context, dollar_1 pgtype.Text) ([]Artist, error) {
rows, err := q.db.Query(ctx, searchArtists, dollar_1)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Artist
for rows.Next() {
var i Artist
if err := rows.Scan(
&i.ID,
&i.Name,
&i.Genre,
&i.Bio,
&i.ArtistImageUrl,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const updateArtist = `-- name: UpdateArtist :exec
UPDATE artists SET name = $2, genre = $3, bio = $4, artist_image_url = $5 WHERE id = $1
`
type UpdateArtistParams struct {
ID pgtype.UUID `json:"id"`
Name string `json:"name"`
Genre pgtype.Text `json:"genre"`
Bio pgtype.Text `json:"bio"`
ArtistImageUrl pgtype.Text `json:"artist_image_url"`
}
func (q *Queries) UpdateArtist(ctx context.Context, arg UpdateArtistParams) error {
_, err := q.db.Exec(ctx, updateArtist,
arg.ID,
arg.Name,
arg.Genre,
arg.Bio,
arg.ArtistImageUrl,
)
return err
}