merch-api/internal/user/repository.go

30 lines
486 B
Go
Raw Normal View History

2026-03-02 17:29:43 +03:00
package user
import "database/sql"
type Repository interface {
getUserId(userUuid string) (string, error)
}
type repo struct {
db *sql.DB
}
func newRepository(db *sql.DB) Repository {
return &repo{
db: db,
}
}
func (r *repo) getUserId(userUuid string) (string, error) {
q := `SELECT id FROM users WHERE uuid = $1 AND deleted_at IS NULL LIMIT 1`
row := r.db.QueryRow(q, userUuid)
var id string
if err := row.Scan(&id); err != nil {
return "", err
}
return id, nil
}