database

package
v0.0.0-...-f98e9bb Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatabaseSqlite = "uniond_sqlite_driver"
)

Variables

This section is empty.

Functions

func Migrate

func Migrate(database Database, files common.VirtualFS) error

func QueryRecord

func QueryRecord[Shape any](database Database, tx *sql.Tx, query string, params ...any) (*Shape, error)

func QueryRecords

func QueryRecords[Shape any](database Database, tx *sql.Tx, query string, params ...any) ([]*Shape, error)

func Record

func Record[Record any](rows *sql.Rows) (*Record, error)

func Records

func Records[Record any](rows *sql.Rows) ([]*Record, error)

func Tx

func Tx[A any](database Database, handler func(*sql.Tx) (*A, error)) (*A, error)

func TxStub

func TxStub(database Database, handler func(*sql.Tx) error) error

Types

type Database

type Database interface {
	Name() string
	Query(tx *sql.Tx, query string, args ...any) (*sql.Rows, error)
	Exec(tx *sql.Tx, query string, args ...any) (sql.Result, error)
	// contains filtered or unexported methods
}

func New

func New(dbPath ...string) (Database, common.Closer, error)

Creates a new sqlite3 database in the DataRoot named {name}.sqlite.

func WithMigrations

func WithMigrations(migrations common.VirtualFS, name ...string) (Database, common.Closer, error)

type Query

type Query string

func (Query) LogValue

func (q Query) LogValue() slog.Value

Jump to

Keyboard shortcuts

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