Distinguish auth/lookup failures, make votes idempotent on visible questions, bound shutdown, page admin users, LRU throttle, trusted-proxy CIDRs, avatar cleanup, versioned migrations, and session cleanup logging.
66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: sessions.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const deleteExpiredSessions = `-- name: DeleteExpiredSessions :execrows
|
|
DELETE FROM sessions
|
|
WHERE expiry <= now()
|
|
`
|
|
|
|
func (q *Queries) DeleteExpiredSessions(ctx context.Context) (int64, error) {
|
|
result, err := q.db.ExecContext(ctx, deleteExpiredSessions)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected()
|
|
}
|
|
|
|
const deleteSession = `-- name: DeleteSession :exec
|
|
DELETE FROM sessions
|
|
WHERE token = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteSession(ctx context.Context, token string) error {
|
|
_, err := q.db.ExecContext(ctx, deleteSession, token)
|
|
return err
|
|
}
|
|
|
|
const getSession = `-- name: GetSession :one
|
|
SELECT data
|
|
FROM sessions
|
|
WHERE token = $1 AND expiry > now()
|
|
`
|
|
|
|
func (q *Queries) GetSession(ctx context.Context, token string) ([]byte, error) {
|
|
row := q.db.QueryRowContext(ctx, getSession, token)
|
|
var data []byte
|
|
err := row.Scan(&data)
|
|
return data, err
|
|
}
|
|
|
|
const upsertSession = `-- 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
|
|
`
|
|
|
|
type UpsertSessionParams struct {
|
|
Token string
|
|
Data []byte
|
|
Expiry time.Time
|
|
}
|
|
|
|
func (q *Queries) UpsertSession(ctx context.Context, arg UpsertSessionParams) error {
|
|
_, err := q.db.ExecContext(ctx, upsertSession, arg.Token, arg.Data, arg.Expiry)
|
|
return err
|
|
}
|