db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 8 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 DeleteZoomLevel = `-- name: DeleteZoomLevel :exec
DELETE FROM zoom_levels WHERE domain = ?
`
View Source
const GetHistory = `` /* 135-byte string literal not displayed */
View Source
const GetShortcuts = `-- name: GetShortcuts :many
SELECT id, shortcut, url_template, description, created_at
FROM shortcuts
ORDER BY shortcut
`
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 ListZoomLevels = `-- name: ListZoomLevels :many
SELECT domain, zoom_factor, updated_at FROM zoom_levels ORDER BY updated_at DESC
`
View Source
const SearchHistory = `` /* 218-byte string literal not displayed */
View Source
const SetZoomLevel = `` /* 233-byte string literal not displayed */

Variables

This section is empty.

Functions

func InitDB

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

InitDB initializes the database connection and schema

func InitDBWithConfig

func InitDBWithConfig(dbPath string, cfg *config.Config) (*sql.DB, error)

InitDBWithConfig initializes the database with configuration-based shortcuts

Types

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
	ShortcutQuerier
}

DatabaseQuerier combines all database operation interfaces

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"`
}

type HistoryQuerier

type HistoryQuerier interface {
	GetHistory(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
}

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
	// Delete zoom level setting for a domain
	DeleteZoomLevel(ctx context.Context, domain string) error
	GetHistory(ctx context.Context, limit int64) ([]History, error)
	GetShortcuts(ctx context.Context) ([]Shortcut, 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)
	// 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
}

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) DeleteZoomLevel

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

Delete zoom level setting for a domain

func (*Queries) GetHistory

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

func (*Queries) GetShortcuts

func (q *Queries) GetShortcuts(ctx context.Context) ([]Shortcut, 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) 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) WithTx

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

type Shortcut

type Shortcut struct {
	ID          int64          `json:"id"`
	Shortcut    string         `json:"shortcut"`
	UrlTemplate string         `json:"url_template"`
	Description sql.NullString `json:"description"`
	CreatedAt   sql.NullTime   `json:"created_at"`
}

type ShortcutQuerier

type ShortcutQuerier interface {
	GetShortcuts(ctx context.Context) ([]Shortcut, error)
}

ShortcutQuerier defines the interface for shortcut-related database operations

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
}

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