-- name: GetSesssion :one
SELECT * FROM sessions WHERE token = $1;

-- name: GetSessions :many
SELECT * FROM sessions WHERE user_id = $1 ORDER BY $2;

-- name: GetActiveSessions :many
SELECT * FROM sessions WHERE user_id = $1 AND (expires > CURRENT_TIMESTAMP OR expires IS NULL) ORDER BY $2;

-- name: CreateSession :exec
INSERT INTO sessions (user_id, title, token) VALUES ($1, $2, $3);

-- name: QuickUpdateSession :exec
UPDATE sessions SET last_activity = GETDATE() WHERE id = $1;

-- name: ExpireSession :exec
UPDATE sessions SET expires = 1 WHERE id = $1;

