database

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAppDataDir

func GetAppDataDir() (string, error)

GetAppDataDir returns the application data directory for macOS

func GetDefaultDatabasePath

func GetDefaultDatabasePath() (string, error)

GetDefaultDatabasePath returns the default SQLite database path

Types

type Config

type Config struct {
	// Type is the database type: "postgres" or "sqlite"
	Type string

	// For PostgreSQL
	PostgresURL string

	// For SQLite
	SQLitePath string
}

Config holds database configuration

type Driver

type Driver interface {
	// DB returns the underlying *sql.DB connection
	DB() *sql.DB

	// Close closes the database connection
	Close() error

	// Initialize sets up the database schema if needed
	Initialize(ctx context.Context) error

	// Type returns the database type (e.g., "postgres", "sqlite")
	Type() string
}

Driver represents a database driver that can be used by the application. This abstraction allows swapping between PostgreSQL and SQLite implementations.

type SQLiteDriver

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

SQLiteDriver implements Driver for SQLite database

func NewSQLiteDriver

func NewSQLiteDriver(dbPath string) (*SQLiteDriver, error)

NewSQLiteDriver creates a new SQLite database driver

func (*SQLiteDriver) Close

func (d *SQLiteDriver) Close() error

Close closes the database connection

func (*SQLiteDriver) DB

func (d *SQLiteDriver) DB() *sql.DB

DB returns the underlying *sql.DB connection

func (*SQLiteDriver) GetAllConfig

func (d *SQLiteDriver) GetAllConfig(ctx context.Context) (map[string]string, error)

GetAllConfig retrieves all configuration values as a map

func (*SQLiteDriver) GetConfig

func (d *SQLiteDriver) GetConfig(ctx context.Context, key string) (string, error)

GetConfig retrieves a configuration value from the database

func (*SQLiteDriver) HasConfig

func (d *SQLiteDriver) HasConfig(ctx context.Context) (bool, error)

HasConfig checks if any config has been saved

func (*SQLiteDriver) Initialize

func (d *SQLiteDriver) Initialize(ctx context.Context) error

Initialize sets up the database schema

func (*SQLiteDriver) SetConfig

func (d *SQLiteDriver) SetConfig(ctx context.Context, key, value string) error

SetConfig stores a configuration value in the database

func (*SQLiteDriver) Type

func (d *SQLiteDriver) Type() string

Type returns the database type

Jump to

Keyboard shortcuts

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