// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: sessions.sql package db import ( "context" "github.com/google/uuid" "github.com/jackc/pgx/v5/pgtype" ) const createSession = `-- name: CreateSession :exec INSERT INTO sessions (id, user_id, token_hash, expires_at) VALUES ($1, $2, $3, $4) ` type CreateSessionParams struct { ID uuid.UUID `json:"id"` UserID uuid.UUID `json:"user_id"` TokenHash string `json:"token_hash"` ExpiresAt pgtype.Timestamptz `json:"expires_at"` } func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) error { _, err := q.db.Exec(ctx, createSession, arg.ID, arg.UserID, arg.TokenHash, arg.ExpiresAt, ) return err } const deleteSession = `-- name: DeleteSession :exec DELETE FROM sessions WHERE token_hash = $1 ` func (q *Queries) DeleteSession(ctx context.Context, tokenHash string) error { _, err := q.db.Exec(ctx, deleteSession, tokenHash) return err } const getSessionUser = `-- name: GetSessionUser :one SELECT user_id FROM sessions WHERE token_hash = $1 AND expires_at > now() ` func (q *Queries) GetSessionUser(ctx context.Context, tokenHash string) (uuid.UUID, error) { row := q.db.QueryRow(ctx, getSessionUser, tokenHash) var user_id uuid.UUID err := row.Scan(&user_id) return user_id, err }