Refactoring for Gin, NoSurf and SCS continues.

This commit is contained in:
2025-10-24 13:08:53 +01:00
parent 7276903733
commit fb07c4a5eb
61 changed files with 546 additions and 524 deletions

View File

@@ -0,0 +1,22 @@
package storage
// ToDo.. "errors" should this not be using my custom log wrapper
import (
"context"
"database/sql"
)
type UsersRepo struct{ db *sql.DB }
func NewUsersRepo(db *sql.DB) *UsersRepo {
return &UsersRepo{db: db}
}
// ToDo: should the function be in sql?
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
}