HN-like selfhosted forums

Code git clone ssh://git.poy.ooo:6969/~rii/district ZIP
store/sessions.sql.go / 1KiB #baad4629
Raw
// Code generated by sqlc. DO NOT EDIT.// versions://   sqlc v1.31.1// source: sessions.sqlpackage storeimport (	"context"	"time"	"github.com/google/uuid")const getSessionByTokenHash = `-- name: GetSessionByTokenHash :oneSELECT s.id, s.user_id, s.token_hash, s.created_at, s.expires_at, s.last_used, s.revoked_at, u.username as session_usernameFROM sessions sJOIN users u ON u.id = s.user_idWHERE token_hash = $1    AND revoked_at IS NULL    AND expires_at > NOW()`type GetSessionByTokenHashRow struct {	ID              uuid.UUID	UserID          uuid.UUID	TokenHash       []byte	CreatedAt       time.Time	ExpiresAt       time.Time	LastUsed        *time.Time	RevokedAt       *time.Time	SessionUsername string}func (q *Queries) GetSessionByTokenHash(ctx context.Context, tokenHash []byte) (GetSessionByTokenHashRow, error) {	row := q.db.QueryRow(ctx, getSessionByTokenHash, tokenHash)	var i GetSessionByTokenHashRow	err := row.Scan(		&i.ID,		&i.UserID,		&i.TokenHash,		&i.CreatedAt,		&i.ExpiresAt,		&i.LastUsed,		&i.RevokedAt,		&i.SessionUsername,	)	return i, err}const newSession = `-- name: NewSession :oneINSERT INTO sessions(user_id, token_hash, expires_at)VALUES ($1, $2, $3)RETURNING id, user_id, token_hash, created_at, expires_at, last_used, revoked_at`type NewSessionParams struct {	UserID    uuid.UUID	TokenHash []byte	ExpiresAt time.Time}func (q *Queries) NewSession(ctx context.Context, arg NewSessionParams) (Session, error) {	row := q.db.QueryRow(ctx, newSession, arg.UserID, arg.TokenHash, arg.ExpiresAt)	var i Session	err := row.Scan(		&i.ID,		&i.UserID,		&i.TokenHash,		&i.CreatedAt,		&i.ExpiresAt,		&i.LastUsed,		&i.RevokedAt,	)	return i, err}const revokeSession = `-- name: RevokeSession :execUPDATE sessionsSET revoked_at = NOW()WHERE id = $1`func (q *Queries) RevokeSession(ctx context.Context, id uuid.UUID) error {	_, err := q.db.Exec(ctx, revokeSession, id)	return err}