-- name: CreateSession :one
INSERT INTO sessions (token, ip_address, user_agent, client_type, expires_at)
VALUES ($1, $2, $3, $4, $5)
RETURNING token, ip_address, user_agent, client_type, expires_at, created_at;

-- name: GetSession :one
SELECT token, ip_address, user_agent, client_type, expires_at, created_at
FROM sessions
WHERE token = $1
LIMIT 1;

-- name: DeleteSession :exec
DELETE FROM sessions
WHERE token = $1;

-- name: DeleteExpiredSessions :exec
DELETE FROM sessions
WHERE expires_at < NOW();

-- name: ListSessions :many
SELECT token, ip_address, user_agent, client_type, expires_at, created_at
FROM sessions
ORDER BY created_at DESC;
