db

package
v0.0.0-pre.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 14 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, 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 MapDBError

func MapDBError(err error) error

func Schema

func Schema() *schema.Schema

Schema for the local database.

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) (*Node, 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) 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