Documentation
¶
Overview ¶
Package csql helps create and manage database connections
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var WireModule = wire.NewSet( NewDBConnection, NewMigrator, LoadConfig, wire.Struct(new(NewMigratorParams), "*"), )
WireModule can be used as part of google/wire setup.
Functions ¶
func GetConn ¶
GetConn returns a db connection from the context or the given default connection if context is empty.
func NewDBConnection ¶
func NewDBConnection(lc *clifecycle.Lifecycle, config Config, logger clogger.Logger) (*gorm.DB, error)
NewDBConnection creates and returns a new database connection. The connection is closed when the app exits.
Types ¶
type Migration ¶
type Migration interface {
Run() error
}
Migration can be implemented by any struct that runs a database migration
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator can run database migrations by running all of the provided migrations
func NewMigrator ¶
func NewMigrator(p NewMigratorParams) *Migrator
NewMigrator creates a new Migrator
type NewMigratorParams ¶
NewMigratorParams holds the params needed for NewMigrator
Click to show internal directories.
Click to hide internal directories.