db

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AddOrUpdateHistory = `` /* 215-byte string literal not displayed */
View Source
const CleanupOldZoomLevels = `-- name: CleanupOldZoomLevels :exec
DELETE FROM zoom_levels WHERE updated_at < datetime('now', '-' || ? || ' days')
`
View Source
const DeleteCertificateValidation = `-- name: DeleteCertificateValidation :exec
DELETE FROM certificate_validations
WHERE hostname = ? AND certificate_hash = ?
`
View Source
const DeleteExpiredCertificateValidations = `` /* 151-byte string literal not displayed */
View Source
const DeleteHistory = `-- name: DeleteHistory :exec
DELETE FROM history
WHERE id = ?
`
View Source
const DeleteZoomLevel = `-- name: DeleteZoomLevel :exec
DELETE FROM zoom_levels WHERE domain = ?
`
View Source
const GetCertificateValidation = `` /* 254-byte string literal not displayed */
View Source
const GetCertificateValidationByHostname = `` /* 264-byte string literal not displayed */
View Source
const GetHistory = `` /* 148-byte string literal not displayed */
View Source
const GetHistoryEntry = `` /* 139-byte string literal not displayed */
View Source
const GetHistoryWithOffset = `` /* 167-byte string literal not displayed */
View Source
const GetZoomLevel = `-- name: GetZoomLevel :one
SELECT zoom_factor FROM zoom_levels WHERE domain = ? LIMIT 1
`
View Source
const GetZoomLevelWithDefault = `` /* 148-byte string literal not displayed */
View Source
const ListCertificateValidations = `` /* 225-byte string literal not displayed */
View Source
const ListZoomLevels = `-- name: ListZoomLevels :many
SELECT domain, zoom_factor, updated_at FROM zoom_levels ORDER BY updated_at DESC
`
View Source
const SearchHistory = `` /* 231-byte string literal not displayed */
View Source
const SetZoomLevel = `` /* 233-byte string literal not displayed */
View Source
const StoreCertificateValidation = `` /* 165-byte string literal not displayed */
View Source
const UpdateHistoryFavicon = `-- name: UpdateHistoryFavicon :exec
UPDATE history
SET favicon_url = ?
WHERE url = ?
`

Variables

This section is empty.

Functions

func InitDB

func InitDB(dbPath string) (*sql.DB, error)

InitDB initializes the database connection and schema

Types

type CertificateQuerier added in v0.13.0

type CertificateQuerier interface {
	ListCertificateValidations(ctx context.Context) ([]CertificateValidation, error)
	GetCertificateValidation(ctx context.Context, hostname string, certificateHash string) (CertificateValidation, error)
	GetCertificateValidationByHostname(ctx context.Context, hostname string) (CertificateValidation, error)
	StoreCertificateValidation(ctx context.Context, hostname string, certificateHash string, userDecision string, expiresAt sql.NullTime) error
	DeleteCertificateValidation(ctx context.Context, hostname string, certificateHash string) error
	DeleteExpiredCertificateValidations(ctx context.Context) error
}

CertificateQuerier defines the interface for certificate validation-related database operations

type CertificateValidation added in v0.7.0

type CertificateValidation struct {
	ID              int64        `json:"id"`
	Hostname        string       `json:"hostname"`
	CertificateHash string       `json:"certificate_hash"`
	UserDecision    string       `json:"user_decision"`
	CreatedAt       sql.NullTime `json:"created_at"`
	ExpiresAt       sql.NullTime `json:"expires_at"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DatabaseQuerier

type DatabaseQuerier interface {
	ZoomQuerier
	HistoryQuerier
	CertificateQuerier
}

DatabaseQuerier combines all database operation interfaces

type FuzzyCacheMetadatum added in v0.13.0

type FuzzyCacheMetadatum struct {
	ID           int64  `json:"id"`
	Version      int64  `json:"version"`
	EntryCount   int64  `json:"entry_count"`
	LastModified int64  `json:"last_modified"`
	EntriesHash  string `json:"entries_hash"`
}

type FuzzyCacheStructure added in v0.13.0

type FuzzyCacheStructure struct {
	ID           int64  `json:"id"`
	TrigramIndex []byte `json:"trigram_index"`
	PrefixTrie   []byte `json:"prefix_trie"`
	SortedIndex  []byte `json:"sorted_index"`
}

type History

type History struct {
	ID          int64          `json:"id"`
	Url         string         `json:"url"`
	Title       sql.NullString `json:"title"`
	VisitCount  sql.NullInt64  `json:"visit_count"`
	LastVisited sql.NullTime   `json:"last_visited"`
	CreatedAt   sql.NullTime   `json:"created_at"`
	FaviconUrl  sql.NullString `json:"favicon_url"`
}

type HistoryQuerier

type HistoryQuerier interface {
	GetHistory(ctx context.Context, limit int64) ([]History, error)
	GetHistoryEntry(ctx context.Context, url string) (History, error)
	GetHistoryWithOffset(ctx context.Context, limit int64, offset int64) ([]History, error)
	SearchHistory(ctx context.Context, column1 sql.NullString, column2 sql.NullString, limit int64) ([]History, error)
	AddOrUpdateHistory(ctx context.Context, url string, title sql.NullString) error
	UpdateHistoryFavicon(ctx context.Context, faviconUrl sql.NullString, url string) error
	DeleteHistory(ctx context.Context, id int64) error
}

HistoryQuerier defines the interface for history-related database operations

type Querier

type Querier interface {
	AddOrUpdateHistory(ctx context.Context, url string, title sql.NullString) error
	// Cleanup zoom level entries older than specified days
	CleanupOldZoomLevels(ctx context.Context, dollar_1 sql.NullString) error
	DeleteCertificateValidation(ctx context.Context, hostname string, certificateHash string) error
	DeleteExpiredCertificateValidations(ctx context.Context) error
	DeleteHistory(ctx context.Context, id int64) error
	// Delete zoom level setting for a domain
	DeleteZoomLevel(ctx context.Context, domain string) error
	GetCertificateValidation(ctx context.Context, hostname string, certificateHash string) (CertificateValidation, error)
	GetCertificateValidationByHostname(ctx context.Context, hostname string) (CertificateValidation, error)
	GetHistory(ctx context.Context, limit int64) ([]History, error)
	GetHistoryEntry(ctx context.Context, url string) (History, error)
	GetHistoryWithOffset(ctx context.Context, limit int64, offset int64) ([]History, error)
	// Get zoom level for a specific domain
	GetZoomLevel(ctx context.Context, domain string) (float64, error)
	// Get zoom level for domain with default fallback
	GetZoomLevelWithDefault(ctx context.Context, domain string) (interface{}, error)
	ListCertificateValidations(ctx context.Context) ([]CertificateValidation, error)
	// List all zoom level settings ordered by most recently updated
	ListZoomLevels(ctx context.Context) ([]ZoomLevel, error)
	SearchHistory(ctx context.Context, column1 sql.NullString, column2 sql.NullString, limit int64) ([]History, error)
	// Set or update zoom level for a domain with validation
	SetZoomLevel(ctx context.Context, domain string, zoomFactor float64) error
	StoreCertificateValidation(ctx context.Context, hostname string, certificateHash string, userDecision string, expiresAt sql.NullTime) error
	UpdateHistoryFavicon(ctx context.Context, faviconUrl sql.NullString, url string) error
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AddOrUpdateHistory

func (q *Queries) AddOrUpdateHistory(ctx context.Context, url string, title sql.NullString) error

func (*Queries) CleanupOldZoomLevels

func (q *Queries) CleanupOldZoomLevels(ctx context.Context, dollar_1 sql.NullString) error

Cleanup zoom level entries older than specified days

func (*Queries) DeleteCertificateValidation added in v0.7.0

func (q *Queries) DeleteCertificateValidation(ctx context.Context, hostname string, certificateHash string) error

func (*Queries) DeleteExpiredCertificateValidations added in v0.7.0

func (q *Queries) DeleteExpiredCertificateValidations(ctx context.Context) error

func (*Queries) DeleteHistory added in v0.8.0

func (q *Queries) DeleteHistory(ctx context.Context, id int64) error

func (*Queries) DeleteZoomLevel

func (q *Queries) DeleteZoomLevel(ctx context.Context, domain string) error

Delete zoom level setting for a domain

func (*Queries) GetCertificateValidation added in v0.7.0

func (q *Queries) GetCertificateValidation(ctx context.Context, hostname string, certificateHash string) (CertificateValidation, error)

func (*Queries) GetCertificateValidationByHostname added in v0.12.0

func (q *Queries) GetCertificateValidationByHostname(ctx context.Context, hostname string) (CertificateValidation, error)

func (*Queries) GetHistory

func (q *Queries) GetHistory(ctx context.Context, limit int64) ([]History, error)

func (*Queries) GetHistoryEntry added in v0.11.0

func (q *Queries) GetHistoryEntry(ctx context.Context, url string) (History, error)

func (*Queries) GetHistoryWithOffset added in v0.8.0

func (q *Queries) GetHistoryWithOffset(ctx context.Context, limit int64, offset int64) ([]History, error)

func (*Queries) GetZoomLevel

func (q *Queries) GetZoomLevel(ctx context.Context, domain string) (float64, error)

Get zoom level for a specific domain

func (*Queries) GetZoomLevelWithDefault

func (q *Queries) GetZoomLevelWithDefault(ctx context.Context, domain string) (interface{}, error)

Get zoom level for domain with default fallback

func (*Queries) ListCertificateValidations added in v0.13.0

func (q *Queries) ListCertificateValidations(ctx context.Context) ([]CertificateValidation, error)

func (*Queries) ListZoomLevels

func (q *Queries) ListZoomLevels(ctx context.Context) ([]ZoomLevel, error)

List all zoom level settings ordered by most recently updated

func (*Queries) SearchHistory

func (q *Queries) SearchHistory(ctx context.Context, column1 sql.NullString, column2 sql.NullString, limit int64) ([]History, error)

func (*Queries) SetZoomLevel

func (q *Queries) SetZoomLevel(ctx context.Context, domain string, zoomFactor float64) error

Set or update zoom level for a domain with validation

func (*Queries) StoreCertificateValidation added in v0.7.0

func (q *Queries) StoreCertificateValidation(ctx context.Context, hostname string, certificateHash string, userDecision string, expiresAt sql.NullTime) error

func (*Queries) UpdateHistoryFavicon added in v0.5.0

func (q *Queries) UpdateHistoryFavicon(ctx context.Context, faviconUrl sql.NullString, url string) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type ZoomLevel

type ZoomLevel struct {
	Domain     string       `json:"domain"`
	ZoomFactor float64      `json:"zoom_factor"`
	UpdatedAt  sql.NullTime `json:"updated_at"`
}

type ZoomQuerier

type ZoomQuerier interface {
	GetZoomLevel(ctx context.Context, domain string) (float64, error)
	SetZoomLevel(ctx context.Context, domain string, zoomLevel float64) error
	DeleteZoomLevel(ctx context.Context, domain string) error
	ListZoomLevels(ctx context.Context) ([]ZoomLevel, error)
}

ZoomQuerier defines the interface for zoom-related database operations

Directories

Path Synopsis
Package mock_db is a generated GoMock package.
Package mock_db is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL