switch to pgx driver + create merch
This commit is contained in:
parent
546fe13107
commit
97f8d27430
13 changed files with 289 additions and 69 deletions
|
|
@ -1,24 +1,27 @@
|
|||
package user
|
||||
|
||||
import "database/sql"
|
||||
import (
|
||||
"context"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
type Repository interface {
|
||||
getUserId(userUuid string) (string, error)
|
||||
getUserId(ctx context.Context, userUuid string) (string, error)
|
||||
}
|
||||
|
||||
type repo struct {
|
||||
db *sql.DB
|
||||
db *pgxpool.Pool
|
||||
}
|
||||
|
||||
func newRepository(db *sql.DB) Repository {
|
||||
func newRepository(db *pgxpool.Pool) Repository {
|
||||
return &repo{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *repo) getUserId(userUuid string) (string, error) {
|
||||
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(q, userUuid)
|
||||
row := r.db.QueryRow(ctx, q, userUuid)
|
||||
|
||||
var id string
|
||||
if err := row.Scan(&id); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue