auth/internal/driver/db/user_passwords.sql.go

80 lines
1.9 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: user_passwords.sql
package db
import (
"context"
"github.com/google/uuid"
)
const createUserPassword = `-- name: CreateUserPassword :exec
INSERT INTO user_passwords (user_id, password_hash, password_salt, algorithm)
VALUES ($1, $2, $3, $4)
`
type CreateUserPasswordParams struct {
UserID uuid.UUID `json:"user_id"`
PasswordHash []byte `json:"password_hash"`
PasswordSalt []byte `json:"password_salt"`
Algorithm string `json:"algorithm"`
}
func (q *Queries) CreateUserPassword(ctx context.Context, arg CreateUserPasswordParams) error {
_, err := q.db.Exec(ctx, createUserPassword,
arg.UserID,
arg.PasswordHash,
arg.PasswordSalt,
arg.Algorithm,
)
return err
}
const getUserPassword = `-- name: GetUserPassword :one
SELECT user_id, password_hash, password_salt, algorithm, created_at, updated_at
FROM user_passwords
WHERE user_id = $1
`
func (q *Queries) GetUserPassword(ctx context.Context, userID uuid.UUID) (UserPassword, error) {
row := q.db.QueryRow(ctx, getUserPassword, userID)
var i UserPassword
err := row.Scan(
&i.UserID,
&i.PasswordHash,
&i.PasswordSalt,
&i.Algorithm,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const updateUserPassword = `-- name: UpdateUserPassword :exec
UPDATE user_passwords
SET password_hash = $1,
password_salt = $2,
algorithm = $3,
updated_at = now()
WHERE user_id = $4
`
type UpdateUserPasswordParams struct {
PasswordHash []byte `json:"password_hash"`
PasswordSalt []byte `json:"password_salt"`
Algorithm string `json:"algorithm"`
UserID uuid.UUID `json:"user_id"`
}
func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error {
_, err := q.db.Exec(ctx, updateUserPassword,
arg.PasswordHash,
arg.PasswordSalt,
arg.Algorithm,
arg.UserID,
)
return err
}