Documentation
¶
Index ¶
- Constants
- Variables
- func Bind(app *runtime.App, db *Database) error
- func Close()
- func Gorm(ctxs ...context.Context) *gorm.DB
- func GormFrom(app *runtime.App) *gorm.DB
- func Init(cfg Config, mode string) error
- func InitWithConfig(cfg Config, mode string) error
- func PGX(ctxs ...context.Context) *pgxpool.Pool
- func PGXFrom(app *runtime.App) *pgxpool.Pool
- func PGXTransaction(ctx context.Context, fn func(tx pgx.Tx) error) error
- func Paginate(page, pageSize int) func(db *gorm.DB) *gorm.DB
- func Table(model interface{}) string
- func TableName(model interface{}) string
- func TableOf[T any](db *Database) string
- func Transaction(ctx context.Context, fn func(tx *gorm.DB) error) error
- type Config
- type Database
- type Page
Constants ¶
View Source
const KeyDatabase runtime.Key = "database"
Variables ¶
Functions ¶
func InitWithConfig ¶
Types ¶
type Config ¶
type Config struct {
Driver string `mapstructure:"driver" yaml:"driver"`
DSN string `mapstructure:"dsn" yaml:"dsn"`
TablePrefix string `mapstructure:"table_prefix" yaml:"table_prefix"`
Schema string `mapstructure:"schema" yaml:"schema"`
MaxOpenConns int `mapstructure:"max_open_conns" yaml:"max_open_conns"`
MaxIdleConns int `mapstructure:"max_idle_conns" yaml:"max_idle_conns"`
ConnMaxLifetime int `mapstructure:"conn_max_lifetime" yaml:"conn_max_lifetime"`
LogLevel string `mapstructure:"log_level" yaml:"log_level"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.