user package

This commit is contained in:
nquidox 2026-03-02 17:29:43 +03:00
parent f962cd8cd9
commit f159014374
4 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,29 @@
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
}