-- users.sql
-- name: CreateUser :one
INSERT INTO users (id, user_name, user_mail, password) VALUES ($1, $2, $3, $4) RETURNING id;

-- name: UpdateUser :exec
UPDATE users SET user_name = $2, user_mail = $3, password = $4 WHERE id = $1;

-- name: GetUsernameByID :one
SELECT user_name FROM users WHERE id = $1;

-- name: CheckUserExistsByEmail :one
SELECT id FROM users WHERE user_mail = $1;

-- name: GetUserByID :one
SELECT id, user_name, user_mail, created_at FROM users WHERE id = $1;

-- name: LoginUser :one
SELECT id, user_name, user_mail FROM users WHERE user_mail = $1 AND password = $2;

-- name: UpdateUserSession :exec
UPDATE users SET session_token = $2, session_expiry = $3 WHERE id = $1;

-- name: logoutUser :exec
-- This is a placeholder for logout functionality, which typically involves token invalidation or session management rather