database

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Driver   string
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
	Path     string // For SQLite
}

Config holds database configuration

func NewConfig

func NewConfig() *Config

NewConfig creates a new database configuration from environment variables

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

DB represents the database connection

func InitDB

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

InitDB initializes the database connection and performs migrations

func InitDBWithConfig

func InitDBWithConfig(config *Config) (*DB, error)

InitDBWithConfig initializes the database with the provided configuration

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

func (*DB) CreateService

func (db *DB) CreateService(ctx context.Context, service *models.ServiceConfiguration) error

CreateService creates a new service configuration

func (*DB) CreateUser

func (db *DB) CreateUser(ctx context.Context, user *types.User) error

CreateUser creates a new user in the database

func (*DB) DeleteService

func (db *DB) DeleteService(ctx context.Context, instanceID string) error

DeleteService deletes a service configuration by its instance ID

func (*DB) FindServiceBy added in v0.3.0

func (db *DB) FindServiceBy(ctx context.Context, params types.FindServiceParams) (*models.ServiceConfiguration, error)

FindServiceBy retrieves a service configuration by FindServiceParams

func (*DB) FindUser added in v0.3.0

func (db *DB) FindUser(ctx context.Context, params types.FindUserParams) (*types.User, error)

FindUser retrieves a user by FindUserParams

func (*DB) GetAllServices

func (db *DB) GetAllServices(ctx context.Context) ([]models.ServiceConfiguration, error)

GetAllServices retrieves all service configurations

func (*DB) GetServiceByInstancePrefix

func (db *DB) GetServiceByInstancePrefix(ctx context.Context, prefix string) (*models.ServiceConfiguration, error)

GetServiceByInstancePrefix retrieves a service configuration by its instance ID prefix

func (*DB) GetUICollapsePreferences added in v0.3.0

func (db *DB) GetUICollapsePreferences(ctx context.Context, userID int64) (map[string]bool, error)

func (*DB) HasUsers

func (db *DB) HasUsers(ctx context.Context) (bool, error)

HasUsers checks if any users exist in the database

func (*DB) Open added in v0.3.0

func (db *DB) Open() error

func (*DB) Path added in v0.2.0

func (db *DB) Path() string

Path returns the database file path (for SQLite)

func (*DB) UpdateService

func (db *DB) UpdateService(ctx context.Context, service *models.ServiceConfiguration) error

UpdateService updates an existing service configuration

func (*DB) UpdateUserPassword

func (db *DB) UpdateUserPassword(ctx context.Context, userID int64, newPasswordHash string) error

UpdateUserPassword updates a user's password hash and updated_at timestamp

func (*DB) UpsertUICollapsePreference added in v0.3.0

func (db *DB) UpsertUICollapsePreference(ctx context.Context, userID int64, key string, collapsed bool) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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