// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: host_refresh_tokens.sql package db import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const deleteExpiredHostRefreshTokens = `-- name: DeleteExpiredHostRefreshTokens :exec DELETE FROM host_refresh_tokens WHERE expires_at < NOW() OR revoked_at IS NOT NULL ` func (q *Queries) DeleteExpiredHostRefreshTokens(ctx context.Context) error { _, err := q.db.Exec(ctx, deleteExpiredHostRefreshTokens) return err } const getHostRefreshTokenByHash = `-- name: GetHostRefreshTokenByHash :one SELECT id, host_id, token_hash, expires_at, created_at, revoked_at FROM host_refresh_tokens WHERE token_hash = $1 AND revoked_at IS NULL AND expires_at > NOW() ` func (q *Queries) GetHostRefreshTokenByHash(ctx context.Context, tokenHash string) (HostRefreshToken, error) { row := q.db.QueryRow(ctx, getHostRefreshTokenByHash, tokenHash) var i HostRefreshToken err := row.Scan( &i.ID, &i.HostID, &i.TokenHash, &i.ExpiresAt, &i.CreatedAt, &i.RevokedAt, ) return i, err } const insertHostRefreshToken = `-- name: InsertHostRefreshToken :one INSERT INTO host_refresh_tokens (id, host_id, token_hash, expires_at) VALUES ($1, $2, $3, $4) RETURNING id, host_id, token_hash, expires_at, created_at, revoked_at ` type InsertHostRefreshTokenParams struct { ID pgtype.UUID `json:"id"` HostID pgtype.UUID `json:"host_id"` TokenHash string `json:"token_hash"` ExpiresAt pgtype.Timestamptz `json:"expires_at"` } func (q *Queries) InsertHostRefreshToken(ctx context.Context, arg InsertHostRefreshTokenParams) (HostRefreshToken, error) { row := q.db.QueryRow(ctx, insertHostRefreshToken, arg.ID, arg.HostID, arg.TokenHash, arg.ExpiresAt, ) var i HostRefreshToken err := row.Scan( &i.ID, &i.HostID, &i.TokenHash, &i.ExpiresAt, &i.CreatedAt, &i.RevokedAt, ) return i, err } const revokeHostRefreshToken = `-- name: RevokeHostRefreshToken :exec UPDATE host_refresh_tokens SET revoked_at = NOW() WHERE id = $1 ` func (q *Queries) RevokeHostRefreshToken(ctx context.Context, id pgtype.UUID) error { _, err := q.db.Exec(ctx, revokeHostRefreshToken, id) return err } const revokeHostRefreshTokensByHost = `-- name: RevokeHostRefreshTokensByHost :exec UPDATE host_refresh_tokens SET revoked_at = NOW() WHERE host_id = $1 AND revoked_at IS NULL ` func (q *Queries) RevokeHostRefreshTokensByHost(ctx context.Context, hostID pgtype.UUID) error { _, err := q.db.Exec(ctx, revokeHostRefreshTokensByHost, hostID) return err }