gorm

package
v0.0.0-...-26e1b9e Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound     = gorm.ErrRecordNotFound
	ErrInvalidTransaction = gorm.ErrInvalidTransaction
	ErrMissingWhereClause = gorm.ErrMissingWhereClause
)

Functions

This section is empty.

Types

type Association

type Association = gorm.Association

type Config

type Config struct {
	Name            string        `json:"name" yaml:"name"`                       //配置名称
	Address         string        `json:"address" yaml:"address"`                 //mysql地址
	DBName          string        `json:"dbName" yaml:"dbName"`                   //数据库名
	User            string        `json:"user" yaml:"user"`                       //用户名
	Password        string        `json:"password" yaml:"password"`               //密码
	Charset         string        `json:"charset" yaml:"charset"`                 //数据库字符集
	DialTimeout     time.Duration `json:"dialTimeout" yaml:"dialTimeout"`         //超时时间 单位:秒
	MaxOpen         int           `json:"maxOpen" yaml:"maxOpen"`                 //最大连接数
	MaxIdle         int           `json:"maxIdle" yaml:"maxIdle"`                 //最大空闲数
	ConnMaxLifetime time.Duration `json:"connMaxLifetime" yaml:"connMaxLifetime"` //连接的最大存活时间 单位:秒
	SlowThreshold   time.Duration `json:"slowThreshold" yaml:"slowThreshold"`     //慢日志阈值 单位:毫秒
	Debug           bool          `json:"debug" yaml:"debug"`                     //是否打印调试日志
	DisableTrace    bool          `json:"disableTrace" yaml:"disableTrace"`       //是否进行链路追踪
}

func DefaultConfig

func DefaultConfig() Config

type DB

type DB = gorm.DB

func CreateSession

func CreateSession(ctx context.Context, db *DB) *DB

func GetDB

func GetDB(key ...string) *DB

func NewClient

func NewClient(config *Config) *DB

type Model

type Model = gorm.Model

type TracePlugin

type TracePlugin struct{}

func (*TracePlugin) Initialize

func (tr *TracePlugin) Initialize(db *xgorm.DB) (err error)

func (*TracePlugin) Name

func (tr *TracePlugin) Name() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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