Add initial database setup and user/artist management functionality
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
db "zardzul/music-index/sqlc"
|
||||
)
|
||||
|
||||
type ArtistRepository interface {
|
||||
GetAll(ctx context.Context) ([]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)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
db "zardzul/music-index/sqlc"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type UserRepository interface {
|
||||
CreateUser(ctx context.Context, arg db.CreateUserParams) (pgtype.UUID, error)
|
||||
GetUsernameByID(ctx context.Context, id pgtype.UUID) (string, error)
|
||||
}
|
||||
|
||||
type SQLCUserRepository struct {
|
||||
q *db.Queries
|
||||
}
|
||||
|
||||
func NewUserRepository(q *db.Queries) *SQLCUserRepository {
|
||||
return &SQLCUserRepository{q: q}
|
||||
}
|
||||
|
||||
func (r *SQLCUserRepository) CreateUser(ctx context.Context, arg db.CreateUserParams) (pgtype.UUID, error) {
|
||||
return r.q.CreateUser(ctx, arg)
|
||||
}
|
||||
|
||||
func (r *SQLCUserRepository) GetUsernameByID(ctx context.Context, id pgtype.UUID) (string, error) {
|
||||
return r.q.GetUsernameByID(ctx, id)
|
||||
}
|
||||
Reference in New Issue
Block a user