db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureSchema

func EnsureSchema(db *sql.DB, dir string) (int, bool, error)

EnsureSchema applies all relevant schema updates to the local database.

Return the initial schema version found before starting the update, along with any error occurred.

func FreshSchema added in v0.2.0

func FreshSchema() string

FreshSchema returns the fresh schema definition of the global database.

func MapDBError

func MapDBError(err error) error

func MaxSupportedSchema added in v0.2.0

func MaxSupportedSchema() int

func Schema

func Schema() *schema.Schema

Schema for the local database.

func SchemaDotGo added in v0.2.0

func SchemaDotGo() error

SchemaDotGo refreshes the schema.go file in this package, using the updates defined here.

Types

type Node

type Node struct {
	DB  *sql.DB // Handle to the local SQLite database file.
	Dir string  // Reference to the directory where the database file lives.
}

Node represents access to the local database.

func OpenDatabase

func OpenDatabase(dir string, applyUpdates bool) (*Node, bool, error)

OpenDatabase creates a new DB object.

Return the newly created DB object.

func (*Node) Close

func (n *Node) Close() error

Close the database facade.

func (*Node) SchemaVersion added in v0.2.0

func (n *Node) SchemaVersion(ctx context.Context) (int64, error)

func (*Node) Transaction

func (n *Node) Transaction(ctx context.Context, f func(context.Context, *sql.Tx) error) error

Transaction executes the database interactions invoked by the given function. If the function returns no error, all database changes are committed to the database, otherwise they are rolled back.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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