tijl.dev-core/modules/database/sessions.sql
tijl a04246cddc
Some checks failed
build / build (push) Failing after 0s
updates
2024-08-21 15:43:24 +02:00

19 lines
562 B
SQL

-- 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;