regenerate sqlc
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user