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) Factory() orm.Factory
- func (d *Database) FlushQueryLog()
- func (d *Database) GetQueryLog() []orm.QueryLog
- func (d *Database) Migrate(paths ...string) error
- func (d *Database) MigrateDown(step int, paths ...string) error
- func (d *Database) MigrateFresh(paths ...string) error
- func (d *Database) MigrateReset(paths ...string) error
- func (d *Database) MigrationStatus(paths ...string) ([]contractsMigration.Status, error)
- func (d *Database) Name() string
- func (d *Database) Observe(model any, observer orm.Observer)
- func (d *Database) Query() orm.Query
- func (d *Database) Schema() *schema.Schema
- func (d *Database) Seed(seeders []contractsseeder.Seeder) error
- func (d *Database) SeedOnce(seeders []contractsseeder.Seeder) error
- func (d *Database) Seeder() contractsseeder.Facade
- 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.
func (*Database) MigrateDown ¶ added in v0.3.0
MigrateDown rolls back the last migration batch.
func (*Database) MigrateFresh ¶ added in v0.3.0
MigrateFresh drops all tables and re-runs all migrations.
func (*Database) MigrateReset ¶ added in v0.3.0
MigrateReset rolls back all migrations and re-runs them.
func (*Database) MigrationStatus ¶ added in v0.3.0
func (d *Database) MigrationStatus(paths ...string) ([]contractsMigration.Status, error)
MigrationStatus returns the status of all migrations.
func (*Database) Seed ¶ added in v0.3.0
func (d *Database) Seed(seeders []contractsseeder.Seeder) error
Seed runs the specified seeders.
func (*Database) SeedOnce ¶ added in v0.3.0
func (d *Database) SeedOnce(seeders []contractsseeder.Seeder) error
SeedOnce runs the specified seeders only once.
func (*Database) Seeder ¶ added in v0.3.0
func (d *Database) Seeder() contractsseeder.Facade
Seeder returns a seeder facade for advanced seeder operations.
type Option ¶
type Option func(*options)
Option is a functional option for configuring the Database.
func SkipPing ¶ added in v0.5.0
func SkipPing() Option
SkipPing skips the initial database ping during connection.
func WithContext ¶
WithContext sets the context for the database.
func WithDebug ¶ added in v0.7.0
func WithDebug() Option
WithDebug enables debug mode 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.