-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
45 lines (40 loc) · 1.82 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package orm
import (
"time"
"github.com/pubgo/funk/config"
"gorm.io/gorm/logger"
)
type Config struct {
TablePrefix string `yaml:"table_prefix"`
Driver string `yaml:"driver"`
DriverCfg config.Node `yaml:"driver_config"`
SkipDefaultTransaction bool `yaml:"skip_default_transaction"`
FullSaveAssociations bool `yaml:"full_save_associations"`
DryRun bool `yaml:"dry_run"`
PrepareStmt bool `yaml:"prepare_stmt"`
DisableAutomaticPing bool `yaml:"disable_automatic_ping"`
DisableForeignKeyConstraintWhenMigrating bool `yaml:"disable_foreign_key_constraint_when_migrating"`
DisableNestedTransaction bool `yaml:"disable_nested_transaction"`
AllowGlobalUpdate bool `yaml:"allow_global_update"`
QueryFields bool `yaml:"query_fields"`
CreateBatchSize int `yaml:"create_batch_size"`
MaxConnTime time.Duration `yaml:"max_conn_time"`
MaxConnIdle int `yaml:"max_conn_idle"`
MaxConnOpen int `yaml:"max_conn_open"`
}
func DefaultCfg() Config {
return Config{
SkipDefaultTransaction: true,
MaxConnTime: time.Hour,
MaxConnIdle: 10,
MaxConnOpen: 100,
}
}
func DefaultLoggerCfg() logger.Config {
return logger.Config{
SlowThreshold: 200 * time.Millisecond,
LogLevel: logger.Info,
IgnoreRecordNotFoundError: false,
Colorful: false,
}
}