db

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 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 CreateFavorite = `` /* 249-byte string literal not displayed */
View Source
const DeleteAllHistory = `-- name: DeleteAllHistory :exec
DELETE FROM history
`
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 DeleteFavorite = `-- name: DeleteFavorite :exec
DELETE FROM favorites
WHERE url = ?
`
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 GetAllFavorites = `` /* 137-byte string literal not displayed */
View Source
const GetCertificateValidation = `` /* 254-byte string literal not displayed */
View Source
const GetCertificateValidationByHostname = `` /* 264-byte string literal not displayed */
View Source
const GetFavoriteByURL = `` /* 137-byte string literal not displayed */
View Source
const GetFavoriteCount = `-- name: GetFavoriteCount :one
SELECT COUNT(*) as count
FROM favorites
`
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 GetMostVisited = `` /* 170-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 IsFavorite = `-- name: IsFavorite :one
SELECT COUNT(*) as count
FROM favorites
WHERE url = ?
LIMIT 1
`
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 UpdateFavorite = `` /* 136-byte string literal not displayed */
View Source
const UpdateFavoritePosition = `` /* 126-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
	FavoritesQuerier
}

DatabaseQuerier combines all database operation interfaces

type Favorite added in v0.14.0

type Favorite struct {
	ID         int64          `json:"id"`
	Url        string         `json:"url"`
	Title      sql.NullString `json:"title"`
	FaviconUrl sql.NullString `json:"favicon_url"`
	Position   int64          `json:"position"`
	CreatedAt  sql.NullTime   `json:"created_at"`
	UpdatedAt  sql.NullTime   `json:"updated_at"`
}

type FavoritesQuerier added in v0.14.0

type FavoritesQuerier interface {
	GetAllFavorites(ctx context.Context) ([]Favorite, error)
	GetFavoriteByURL(ctx context.Context, url string) (Favorite, error)
	CreateFavorite(ctx context.Context, url string, title sql.NullString, faviconUrl sql.NullString) error
	UpdateFavorite(ctx context.Context, title sql.NullString, faviconUrl sql.NullString, url string) error
	DeleteFavorite(ctx context.Context, url string) error
	IsFavorite(ctx context.Context, url string) (int64, error)
	UpdateFavoritePosition(ctx context.Context, position int64, url string) error
	GetFavoriteCount(ctx context.Context) (int64, error)
}

FavoritesQuerier defines the interface for favorites-related database operations

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)
	GetMostVisited(ctx context.Context, limit 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
	DeleteAllHistory(ctx context.Context) 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
	// Insert a new favorite with auto-incremented position
	CreateFavorite(ctx context.Context, url string, title sql.NullString, faviconUrl sql.NullString) error
	DeleteAllHistory(ctx context.Context) error
	DeleteCertificateValidation(ctx context.Context, hostname string, certificateHash string) error
	DeleteExpiredCertificateValidations(ctx context.Context) error
	// Delete a favorite by URL
	DeleteFavorite(ctx context.Context, url string) error
	DeleteHistory(ctx context.Context, id int64) error
	// Delete zoom level setting for a domain
	DeleteZoomLevel(ctx context.Context, domain string) error
	// Get all favorites ordered by position
	GetAllFavorites(ctx context.Context) ([]Favorite, error)
	GetCertificateValidation(ctx context.Context, hostname string, certificateHash string) (CertificateValidation, error)
	GetCertificateValidationByHostname(ctx context.Context, hostname string) (CertificateValidation, error)
	// Get a specific favorite by URL
	GetFavoriteByURL(ctx context.Context, url string) (Favorite, error)
	// Get total count of favorites
	GetFavoriteCount(ctx context.Context) (int64, 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)
	GetMostVisited(ctx context.Context, limit 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)
	// Check if a URL is favorited
	IsFavorite(ctx context.Context, url string) (int64, 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
	// Update favorite metadata (title, favicon)
	UpdateFavorite(ctx context.Context, title sql.NullString, faviconUrl sql.NullString, url string) error
	// Update the position of a favorite
	UpdateFavoritePosition(ctx context.Context, position int64, url string) 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) CreateFavorite added in v0.14.0

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

Insert a new favorite with auto-incremented position

func (*Queries) DeleteAllHistory added in v0.15.0

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

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) DeleteFavorite added in v0.14.0

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

Delete a favorite by URL

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) GetAllFavorites added in v0.14.0

func (q *Queries) GetAllFavorites(ctx context.Context) ([]Favorite, error)

Get all favorites ordered by position

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) GetFavoriteByURL added in v0.14.0

func (q *Queries) GetFavoriteByURL(ctx context.Context, url string) (Favorite, error)

Get a specific favorite by URL

func (*Queries) GetFavoriteCount added in v0.14.0

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

Get total count of favorites

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) GetMostVisited added in v0.15.0

func (q *Queries) GetMostVisited(ctx context.Context, limit 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) IsFavorite added in v0.14.0

func (q *Queries) IsFavorite(ctx context.Context, url string) (int64, error)

Check if a URL is favorited

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) UpdateFavorite added in v0.14.0

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

Update favorite metadata (title, favicon)

func (*Queries) UpdateFavoritePosition added in v0.14.0

func (q *Queries) UpdateFavoritePosition(ctx context.Context, position int64, url string) error

Update the position of a favorite

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