// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: artists.sql package sqlc import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const createArtist = `-- name: CreateArtist :one INSERT INTO artists (id, name, genre, bio, artist_image_url) VALUES ($1, $2, $3, $4, $5) RETURNING id ` type CreateArtistParams 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) CreateArtist(ctx context.Context, arg CreateArtistParams) (pgtype.UUID, error) { row := q.db.QueryRow(ctx, createArtist, arg.ID, arg.Name, arg.Genre, arg.Bio, arg.ArtistImageUrl, ) var id pgtype.UUID err := row.Scan(&id) 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 ` func (q *Queries) GetAllArtists(ctx context.Context) ([]Artist, error) { rows, err := q.db.Query(ctx, getAllArtists) 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 getArtistByID = `-- name: GetArtistByID :one SELECT id, name, genre, bio, artist_image_url FROM artists WHERE id = $1 ` // artists.sql func (q *Queries) GetArtistByID(ctx context.Context, id pgtype.UUID) (Artist, error) { row := q.db.QueryRow(ctx, getArtistByID, id) var i Artist err := row.Scan( &i.ID, &i.Name, &i.Genre, &i.Bio, &i.ArtistImageUrl, ) 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 }