merch-api/internal/user/repository.go
2026-03-04 17:02:11 +03:00

32 lines
580 B
Go

package user
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
)
type Repository interface {
getUserId(ctx context.Context, userUuid string) (string, error)
}
type repo struct {
db *pgxpool.Pool
}
func newRepository(db *pgxpool.Pool) Repository {
return &repo{
db: db,
}
}
func (r *repo) getUserId(ctx context.Context, userUuid string) (string, error) {
q := `SELECT id FROM users WHERE uuid = $1 AND deleted_at IS NULL LIMIT 1`
row := r.db.QueryRow(ctx, q, userUuid)
var id string
if err := row.Scan(&id); err != nil {
return "", err
}
return id, nil
}