database

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

reader/writer fields on DB

func New

func New(databasePath string) (*DB, error)

func (*DB) BeginTx added in v1.6.0

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

BeginTx starts a transaction. Note that transactions bypass the single writer and use the underlying connection pool directly. This is safe because SQLite handles transaction serialization internally.

func (*DB) Close

func (db *DB) Close() error

func (*DB) Conn

func (db *DB) Conn() *sql.DB

func (*DB) ExecContext added in v1.6.0

func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext routes write queries through the single writer goroutine and uses prepared statements when possible. Do NOT use this for queries with RETURNING clauses - use QueryRowContext or QueryContext instead.

func (*DB) QueryContext added in v1.6.0

func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)

QueryContext uses reader pool and prepared statements

func (*DB) QueryRowContext added in v1.6.0

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row

QueryRowContext uses QueryContext and scans first row

type LicenseRepo added in v1.0.0

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

func NewLicenseRepo added in v1.0.0

func NewLicenseRepo(db *DB) *LicenseRepo

func (*LicenseRepo) DeleteLicense added in v1.0.0

func (r *LicenseRepo) DeleteLicense(ctx context.Context, licenseKey string) error

DeleteLicense removes a license from the database

func (*LicenseRepo) GetAllLicenses added in v1.0.0

func (r *LicenseRepo) GetAllLicenses(ctx context.Context) ([]*models.ProductLicense, error)

GetAllLicenses retrieves all licenses

func (*LicenseRepo) GetLicenseByKey added in v1.0.0

func (r *LicenseRepo) GetLicenseByKey(ctx context.Context, licenseKey string) (*models.ProductLicense, error)

GetLicenseByKey retrieves a license by its key

func (*LicenseRepo) HasPremiumAccess added in v1.0.0

func (r *LicenseRepo) HasPremiumAccess(ctx context.Context) (bool, error)

HasPremiumAccess checks if the user has purchased premium access (one-time unlock)

func (*LicenseRepo) StoreLicense added in v1.0.0

func (r *LicenseRepo) StoreLicense(ctx context.Context, license *models.ProductLicense) error

func (*LicenseRepo) UpdateLicenseActivation added in v1.0.0

func (r *LicenseRepo) UpdateLicenseActivation(ctx context.Context, license *models.ProductLicense) error

UpdateLicenseActivation updates a license with activation details

func (*LicenseRepo) UpdateLicenseStatus added in v1.0.0

func (r *LicenseRepo) UpdateLicenseStatus(ctx context.Context, licenseID int, status string) error

func (*LicenseRepo) UpdateLicenseValidation added in v1.0.0

func (r *LicenseRepo) UpdateLicenseValidation(ctx context.Context, license *models.ProductLicense) error

Jump to

Keyboard shortcuts

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