22 lines
758 B
SQL
22 lines
758 B
SQL
-- name: SelectUserById :one
|
|
SELECT id, username, email, password_hash, created_at, updated_at
|
|
FROM user_auth
|
|
WHERE id = $1;
|
|
|
|
-- name: SelectUserByUsername :one
|
|
SELECT id, username, email, password_hash, created_at, updated_at
|
|
FROM user_auth
|
|
WHERE username = $1;
|
|
|
|
-- name: InsertUser :one
|
|
INSERT INTO user_auth (username, email, password_hash)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING id, username, email, password_hash, created_at, updated_at;
|
|
|
|
-- name: PatchUser :one
|
|
UPDATE user_auth
|
|
SET username = COALESCE(sqlc.narg(username), username),
|
|
email = COALESCE(sqlc.narg(email), email),
|
|
password_hash = COALESCE(sqlc.narg(password_hash), password_hash)
|
|
WHERE id = sqlc.arg(id)
|
|
RETURNING id, username, email, password_hash, created_at, updated_at;
|