gormdb

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Read  *gorm.DB
	Write *gorm.DB
)
View Source
var (
	DefaultCustomOptions = &CustomOptions{
		GormConfig: &gorm.Config{},
	}
)

Functions

func InitDB

func InitDB() (err error)

func New

func New(config gormLog.Config) gormLog.Interface

func NewReadSession

func NewReadSession() (db *gorm.DB)

func NewReadSessionWithOptions

func NewReadSessionWithOptions(options *gorm.Session) (db *gorm.DB)

func NewWriteSession

func NewWriteSession() (db *gorm.DB)

func NewWriteSessionWithOptions

func NewWriteSessionWithOptions(options *gorm.Session) (db *gorm.DB)

Types

type BaseOptions

type BaseOptions struct {
	ReadDns     string
	WriteDns    string
	Logger      Log
	MaxIdleConn int
	MaxOpenConn int
	MaxLifetime time.Duration
	TablePrefix string
}

type CustomOptions

type CustomOptions struct {
	GormConfig *gorm.Config
}

type GormLog

type GormLog struct {
	gormLog.Config
	// contains filtered or unexported fields
}

func (GormLog) Error

func (l GormLog) Error(ctx context.Context, msg string, data ...interface{})

Error print error messages

func (GormLog) Info

func (l GormLog) Info(ctx context.Context, msg string, data ...interface{})

Info print info

func (*GormLog) LogMode

func (l *GormLog) LogMode(level gormLog.LogLevel) gormLog.Interface

LogMode log mode

func (GormLog) Trace

func (l GormLog) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace print sql message

func (GormLog) Warn

func (l GormLog) Warn(ctx context.Context, msg string, data ...interface{})

Warn print warn messages

type Log

type Log struct {
	ShowLog                   bool
	SlowThreshold             time.Duration
	IgnoreRecordNotFoundError bool
	LogLevel                  gormLog.LogLevel
}

Jump to

Keyboard shortcuts

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