db

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentVersion = 3

CurrentVersion is the current version of the database. The database is reset if its version doesn't match this.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	GetPaths() *config.Paths
}

type Database

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

func New

func New(config Config) *Database

func (*Database) Close

func (d *Database) Close() error

func (*Database) Connect

func (d *Database) Connect(ctx context.Context) error

func (*Database) DeletePkgs

func (d *Database) DeletePkgs(ctx context.Context, where string, args ...any) error

func (*Database) GetConn

func (d *Database) GetConn() *sqlx.DB

func (*Database) GetPkg

func (d *Database) GetPkg(ctx context.Context, where string, args ...any) (*Package, error)

func (*Database) GetPkgs

func (d *Database) GetPkgs(ctx context.Context, where string, args ...any) (*sqlx.Rows, error)

func (*Database) GetVersion

func (d *Database) GetVersion(ctx context.Context) (int, bool)

func (*Database) Init

func (d *Database) Init(ctx context.Context) error

func (*Database) InsertPackage

func (d *Database) InsertPackage(ctx context.Context, pkg Package) error

func (*Database) IsEmpty

func (d *Database) IsEmpty(ctx context.Context) bool

type JSON

type JSON[T any] struct {
	Val T
}

JSON represents a JSON value in the database

func NewJSON

func NewJSON[T any](v T) JSON[T]

NewJSON creates a new database JSON value

func (JSON[T]) GoString

func (s JSON[T]) GoString() string

func (JSON[T]) MarshalYAML

func (s JSON[T]) MarshalYAML() (any, error)

func (*JSON[T]) Scan

func (s *JSON[T]) Scan(val any) error

func (JSON[T]) String

func (s JSON[T]) String() string

func (JSON[T]) Value

func (s JSON[T]) Value() (driver.Value, error)

type Package

type Package struct {
	BasePkgName   string                    `sh:"base" db:"basepkg_name"`
	Name          string                    `sh:"name,required" db:"name"`
	Version       string                    `sh:"version,required" db:"version"`
	Release       int                       `sh:"release,required" db:"release"`
	Epoch         uint                      `sh:"epoch" db:"epoch"`
	Description   JSON[map[string]string]   `db:"description"`
	Homepage      JSON[map[string]string]   `db:"homepage"`
	Maintainer    JSON[map[string]string]   `db:"maintainer"`
	Architectures JSON[[]string]            `sh:"architectures" db:"architectures"`
	Licenses      JSON[[]string]            `sh:"license" db:"licenses"`
	Provides      JSON[[]string]            `sh:"provides" db:"provides"`
	Conflicts     JSON[[]string]            `sh:"conflicts" db:"conflicts"`
	Replaces      JSON[[]string]            `sh:"replaces" db:"replaces"`
	Depends       JSON[map[string][]string] `db:"depends"`
	BuildDepends  JSON[map[string][]string] `db:"builddepends"`
	OptDepends    JSON[map[string][]string] `db:"optdepends"`
	Repository    string                    `db:"repository"`
}

Package is a ALR package's database representation

Jump to

Keyboard shortcuts

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