database

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database is the main entry point for the neat package.

func New

func New(cfg db.DBConfig, opts ...Option) (*Database, error)

New creates a new Database instance from a DBConfig.

func NewFromDSN

func NewFromDSN(dsn string, opts ...Option) (*Database, error)

NewFromDSN creates a new Database instance from a DSN string. Supported DSN formats: - postgres://user:pass@localhost:5432/mydb?sslmode=disable - mysql://user:pass@localhost:3306/mydb - sqlite://path/to/database.db

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection.

func (*Database) Connection

func (d *Database) Connection(name string) (*Database, error)

Connection returns a new Database instance for a different connection.

func (*Database) DB

func (d *Database) DB() (*sql.DB, error)

DB returns the underlying database connection.

func (*Database) DatabaseName

func (d *Database) DatabaseName() string

DatabaseName returns the name of the current database.

func (*Database) DisableQueryLog

func (d *Database) DisableQueryLog()

DisableQueryLog disables the capturing of executed queries.

func (*Database) EnableQueryLog

func (d *Database) EnableQueryLog()

EnableQueryLog enables the capturing of executed queries.

func (*Database) FlushQueryLog

func (d *Database) FlushQueryLog()

FlushQueryLog clears the captured queries from the log.

func (*Database) GetQueryLog

func (d *Database) GetQueryLog() []orm.QueryLog

GetQueryLog retrieves the captured queries from the log.

func (*Database) Query

func (d *Database) Query() orm.Query

Query returns the ORM query builder.

func (*Database) Schema

func (d *Database) Schema() *schema.Schema

Schema returns the schema builder. Note: Schema initialization requires a config adapter to convert db.DBConfig to config.Config This is deferred until the config adapter is implemented.

func (*Database) Transaction

func (d *Database) Transaction(txFunc func(tx orm.Query) error, opts ...*sql.TxOptions) error

Transaction executes a function within a database transaction.

type Option

type Option func(*options)

Option is a functional option for configuring the Database.

func WithContext

func WithContext(ctx context.Context) Option

WithContext sets the context for the database.

func WithEventBus

func WithEventBus(eventBus *databaseorm.EventBus) Option

WithEventBus sets the event bus for the database.

func WithLogger

func WithLogger(logger log.Log) Option

WithLogger sets the logger for the database.

func WithPool

func WithPool(pool db.PoolConfig) Option

WithPool sets the connection pool configuration for the database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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