db

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentVersion = 2

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

func Close

func Close() error

Close closes the database

func DB

func DB(ctx context.Context) *sqlx.DB

DB returns the LURE database. The first time it's called, it opens the SQLite database file. Subsequent calls return the same connection.

func DeletePkgs

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

DeletePkgs deletes all packages matching the where conditions

func GetPkgs

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

GetPkgs returns a result containing packages that match the where conditions

func GetVersion

func GetVersion(ctx context.Context) (int, bool)

GetVersion returns the database version and a boolean indicating whether the database contained a version number

func InsertPackage

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

InsertPackage adds a package to the database

func IsEmpty

func IsEmpty(ctx context.Context) bool

IsEmpty returns true if the database has no packages in it, otherwise it returns false.

Types

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 {
	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 LURE package's database representation

func GetPkg

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

GetPkg returns a single package that matches the where conditions

Jump to

Keyboard shortcuts

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