-- name: GetSession :one
SELECT data
FROM sessions
WHERE token = $1 AND expiry > now();

-- name: UpsertSession :exec
INSERT INTO sessions (token, data, expiry)
VALUES ($1, $2, $3)
ON CONFLICT (token) DO UPDATE
SET data = excluded.data, expiry = excluded.expiry;

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

-- name: DeleteExpiredSessions :exec
DELETE FROM sessions
WHERE expiry <= now();
