Documentation
¶
Index ¶
- Variables
- func Configs() map[string]interface{}
- func Range(fn func(name string, db *DB) bool)
- func Stats() (stats map[string]interface{})
- type Association
- type Callback
- type CallbackProcessor
- type Config
- type DB
- type DSN
- type Dialect
- type Errors
- type Field
- type Handler
- type Interceptor
- type Logger
- type Model
- type ModelStruct
- type RowQueryResult
- type RowsQueryResult
- type SQLCommon
- type Scope
- type StructField
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // IsRecordNotFoundError ... IsRecordNotFoundError = gorm.IsRecordNotFoundError // ErrRecordNotFound returns a "record not found error". Occurs only when attempting to query the database with a struct; querying with a slice won't return this error ErrRecordNotFound = gorm.ErrRecordNotFound // ErrInvalidSQL occurs when you attempt a query with invalid SQL ErrInvalidSQL = gorm.ErrInvalidSQL // ErrInvalidTransaction occurs when you are trying to `Commit` or `Rollback` ErrInvalidTransaction = gorm.ErrInvalidTransaction // ErrCantStartTransaction can't start transaction when you are trying to start one with `Begin` ErrCantStartTransaction = gorm.ErrCantStartTransaction // ErrUnaddressable unaddressable value ErrUnaddressable = gorm.ErrUnaddressable )
Functions ¶
Types ¶
type CallbackProcessor ¶
type CallbackProcessor = gorm.CallbackProcessor
CallbackProcessor alias of gorm.CallbackProcessor
type Config ¶
type Config struct {
Name string
// DSN地址: mysql://root:secret@tcp(127.0.0.1:3307)/mysql?timeout=20s&readTimeout=20s
DSN string `json:"dsn" toml:"dsn"`
// Debug开关
Debug bool `json:"debug" toml:"debug"`
// 最大空闲连接数
MaxIdleConns int `json:"maxIdleConns" toml:"maxIdleConns"`
// 最大活动连接数
MaxOpenConns int `json:"maxOpenConns" toml:"maxOpenConns"`
// 连接的最大存活时间
ConnMaxLifetime time.Duration `json:"connMaxLifetime" toml:"connMaxLifetime"`
// 创建连接的错误级别,=panic时,如果创建失败,立即panic
OnDialError string `json:"level" toml:"level"`
// 慢日志阈值
SlowThreshold time.Duration `json:"slowThreshold" toml:"slowThreshold"`
// 拨超时时间
DialTimeout time.Duration `json:"dialTimeout" toml:"dialTimeout"`
// 关闭指标采集
DisableMetric bool `json:"disableMetric" toml:"disableMetric"`
// 关闭链路追踪
DisableTrace bool `json:"disableTrace" toml:"disableTrace"`
// 记录错误sql时,是否打印包含参数的完整sql语句
// select * from aid = ?;
// select * from aid = 288016;
DetailSQL bool `json:"detailSql" toml:"detailSql"`
// contains filtered or unexported fields
}
config options
func (*Config) WithInterceptor ¶
func (config *Config) WithInterceptor(intes ...Interceptor) *Config
WithInterceptor ...
type DSN ¶
type DSN struct {
User string // Username
Password string // Password (requires User)
Net string // Network type
Addr string // Network address (requires Net)
DBName string // Database name
Params map[string]string // Connection parameters
}
DSN ...
type Interceptor ¶
Interceptor ...
Click to show internal directories.
Click to hide internal directories.