vdb

package
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package vdb

Package vdb

Index

Constants

View Source
const (
	// DefaultMaxIdleConn default max idle conns
	DefaultMaxIdleConn = 1
	DefaultMaxOpenConn = 10
)

Variables

This section is empty.

Functions

func NewConnect

func NewConnect(ctx context.Context, key string) (db *gorm.DB)

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

func NewConnectWithConfig(ctx context.Context, config *Config) (db *gorm.DB)

NewConnectWithConfig via config connect new

func NewGormLog

func NewGormLog(option ...GormLogOptions) gLogger.Interface

NewGormLog creates a new GormLogger instance with the provided options.

func NewQuickConnect added in v0.0.17

func NewQuickConnect(ctx context.Context, key string) (db *gorm.DB)

NewQuickConnect via framework config connect new

the_key:
  host: ""
  port: 3306
  user: ""
  password: ""
  schema: ""
  charset: "utf8mb4"
  maxOpenConn: 10
  maxIdleConn: 10
  debug: true

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

func (*Config) Hash added in v0.0.18

func (c *Config) Hash() (string, error)

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

type GormLogger struct {
	SlowThreshold time.Duration
	Name          []string
}

func (GormLogger) Error

func (gl GormLogger) Error(ctx context.Context, s string, v ...interface{})

func (GormLogger) Info

func (gl GormLogger) Info(ctx context.Context, s string, v ...interface{})

func (GormLogger) LogMode

func (gl GormLogger) LogMode(level gLogger.LogLevel) gLogger.Interface

func (GormLogger) Trace

func (gl GormLogger) Trace(ctx context.Context, begin time.Time,
	fc func() (sql string, rowsAffected int64), err error)

func (GormLogger) Warn

func (gl GormLogger) Warn(ctx context.Context, s string, v ...interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL