30 lines
679 B
Go
30 lines
679 B
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
db "zardzul/music-index/sqlc"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
type ArtistRepository interface {
|
|
GetAll(ctx context.Context) ([]db.Artist, error)
|
|
GetByID(ctx context.Context, id pgtype.UUID) (db.Artist, error)
|
|
}
|
|
|
|
type SQLCArtistRepository struct {
|
|
q *db.Queries
|
|
}
|
|
|
|
func NewArtistRepository(queries *db.Queries) *SQLCArtistRepository {
|
|
return &SQLCArtistRepository{q: queries}
|
|
}
|
|
|
|
func (r *SQLCArtistRepository) GetAll(ctx context.Context) ([]db.Artist, error) {
|
|
return r.q.GetAllArtists(ctx)
|
|
}
|
|
|
|
func (r *SQLCArtistRepository) GetByID(ctx context.Context, id pgtype.UUID) (db.Artist, error) {
|
|
return r.q.GetArtistByID(ctx, id)
|
|
}
|