Documentation
¶
Index ¶
- func New(ctx context.Context, dsn string, logger log.Logger, opts ...Option) (*gorm.DB, error)
- type Option
- func WithConnMaxIdleTime(t time.Duration) Option
- func WithConnMaxLifetime(t time.Duration) Option
- func WithDryRun(b bool) Option
- func WithIgnoreRecordNotFoundError(b bool) Option
- func WithMaxIdleConns(n int) Option
- func WithMaxOpenConns(n int) Option
- func WithParameterizedQueries(b bool) Option
- func WithSlowThreshold(t time.Duration) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*Options)
func WithConnMaxIdleTime ¶
func WithConnMaxLifetime ¶
func WithDryRun ¶ added in v0.7.13
func WithIgnoreRecordNotFoundError ¶ added in v0.7.13
func WithMaxIdleConns ¶
func WithMaxOpenConns ¶
func WithParameterizedQueries ¶ added in v0.7.13
func WithSlowThreshold ¶ added in v0.7.13
type Options ¶
type Options struct { MaxIdleConns int // 最大空闲连接数 MaxOpenConns int // 最大打开连接数 ConnMaxLifetime time.Duration // 连接重用最大时间 ConnMaxIdleTime time.Duration // 连接空闲最大时间 SlowThreshold time.Duration // TraceLog打印慢查询日志时的阈值 IgnoreRecordNotFoundError bool // TraceLog打印错误日志时是否忽略RecordNotFound错误 ParameterizedQueries bool // TraceLog打印日志时SQL语句是否使用?占位符代替实际的参数 DryRun bool // 生成SQL但不执行 }
Click to show internal directories.
Click to hide internal directories.