Refactor and remove sqlite and replace with MySQL
This commit is contained in:
22
internal/storage/mysql/users/create.go
Normal file
22
internal/storage/mysql/users/create.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package storage
|
||||
|
||||
// ToDo.. "errors" should this not be using my custom log wrapper
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
|
||||
"synlotto-website/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
|
||||
}
|
||||
Reference in New Issue
Block a user