22 lines
539 B
Go
22 lines
539 B
Go
package storage
|
|
|
|
// ToDo.. "errors" should this not be using my custom log wrapper
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"errors"
|
|
|
|
"synlotto-website/internal/models"
|
|
)
|
|
|
|
type UsersRepo struct{ db *sql.DB}
|
|
|
|
func NewUsersRepo(db *.sql.DB) *UsersRepo { return &UsersRepo{db: db} }
|
|
|
|
func (r *UsersRepo) Create(ctx context.Context, username, passwordHash string, isAdmin bool) error {
|
|
_, err := r.db.ExecContext(ctx,
|
|
`INSERT INTO users (username, password_hash, is_admin) VALUES (?, ?, ?)`,
|
|
username, passwordHash, isAdmin,
|
|
)
|
|
return err
|
|
} |