Documentation
¶
Overview ¶
Package vdb
Package vdb
Index ¶
- Constants
- func NewConnect(ctx context.Context, key string) (db *gorm.DB)
- func NewConnectWithConfig(ctx context.Context, config *Config) (db *gorm.DB)
- func NewGormLog(option ...GormLogOptions) gLogger.Interface
- func NewQuickConnect(ctx context.Context, key string) (db *gorm.DB)
- type Config
- type GormLogOptions
- type GormLogger
- func (gl GormLogger) Error(ctx context.Context, s string, v ...interface{})
- func (gl GormLogger) Info(ctx context.Context, s string, v ...interface{})
- func (gl GormLogger) LogMode(level gLogger.LogLevel) gLogger.Interface
- func (gl GormLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (gl GormLogger) Warn(ctx context.Context, s string, v ...interface{})
Constants ¶
View Source
const ( // DefaultMaxIdleConn default max idle conns DefaultMaxIdleConn = 1 DefaultMaxOpenConn = 10 )
Variables ¶
This section is empty.
Functions ¶
func NewConnect ¶
NewConnect establishes a new database connection based on the provided context and key.
Parameters: - ctx: the context used for the database connection. - key: the key to retrieve database connection configuration details.
Returns a *gorm.DB representing the established database connection. Deprecated: use NewQuickConnect instead.
func NewConnectWithConfig ¶ added in v0.0.17
NewConnectWithConfig via config connect new
func NewGormLog ¶
func NewGormLog(option ...GormLogOptions) gLogger.Interface
NewGormLog creates a new GormLogger instance with the provided options.
Types ¶
type Config ¶ added in v0.0.17
type Config struct { User string Password string Host string Port int Schema string Charset string ParseTime bool MaxOpenConn int MaxIdleConn int ConnMaxLifeTime time.Duration Debug bool }
Config connect config
type GormLogOptions ¶
type GormLogOptions func(*GormLogger)
func GormLogWithName ¶
func GormLogWithName(name ...string) GormLogOptions
GormLogWithName defines a function that sets the name for GormLogger.
func GormLogWithSlowThreshold ¶
func GormLogWithSlowThreshold(st time.Duration) GormLogOptions
GormLogWithSlowThreshold defines a function that sets the slow threshold for GormLogger.
type GormLogger ¶
func (GormLogger) Error ¶
func (gl GormLogger) Error(ctx context.Context, s string, v ...interface{})
Click to show internal directories.
Click to hide internal directories.