Documentation
¶
Index ¶
- type Database
- func (d *Database) Close() error
- func (d *Database) Connection(name string) (*Database, error)
- func (d *Database) DB() (*sql.DB, error)
- func (d *Database) DatabaseName() string
- func (d *Database) DisableQueryLog()
- func (d *Database) EnableQueryLog()
- func (d *Database) FlushQueryLog()
- func (d *Database) GetQueryLog() []orm.QueryLog
- func (d *Database) Name() string
- func (d *Database) Query() orm.Query
- func (d *Database) Schema() *schema.Schema
- func (d *Database) Transaction(txFunc func(tx orm.Query) error, opts ...*sql.TxOptions) error
- type Option
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 NewFromDSN ¶
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) Connection ¶
Connection returns a new Database instance for a different connection.
func (*Database) DatabaseName ¶
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 ¶
GetQueryLog retrieves the captured queries from the log.
type Option ¶
type Option func(*options)
Option is a functional option for configuring the Database.
func WithContext ¶
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 ¶
WithLogger sets the logger for the database.
func WithPool ¶
func WithPool(pool db.PoolConfig) Option
WithPool sets the connection pool configuration for the database.