-- name: GetUserById :one
SELECT *
FROM users u
WHERE u.id = @user_id::uuid;

-- name: GetUserAuthValue :one
SELECT u.ID as user_id, a.value as auth_value
FROM users u
    JOIN auth_method a
        ON a.user_id = u.id
WHERE
    (u.name = @auth_value::text OR u.email = @auth_value)
    AND a.type = @auth_type::auth_type;

-- name: CreateUser :one
INSERT INTO users (name, email, bio, profile_photo)
VALUES($1, $2, $3, $4)
RETURNING *;

-- name: UpdateUser :one
UPDATE users
SET name = @name::text, email = @email::text, bio = @bio::text, profile_photo = @photo::text
WHERE id = @id::uuid
RETURNING *;

-- name: CreateAuthMethod :exec
INSERT INTO auth_method (user_id, type, value)
VALUES ($1, $2, $3);
