Skip to content

Commit

Permalink
Merge pull request #191 from sunmi-OS/feature/imp
Browse files Browse the repository at this point in the history
update orm
  • Loading branch information
luduoxin authored Feb 6, 2025
2 parents a80e62e + 4721308 commit 32af8af
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions db/orm/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ func openORM(dbname string) (*gorm.DB, error) {
db.SetMaxIdleConns(viper.C.GetInt(dbname + ".MaxIdleConns"))
// 最大打开连接数
db.SetMaxOpenConns(viper.C.GetInt(dbname + ".MaxOpenConns"))
// Set connMaxIdleTime
connMaxIdleTime := viper.GetEnvConfig(dbname + ".ConnMaxIdleTime").Int64()
if connMaxIdleTime > 0 {
db.SetConnMaxIdleTime(time.Duration(connMaxIdleTime) * time.Second)
}
return orm, nil
default:
return nil, fmt.Errorf("not support sql driver [%s]", dbType)
Expand Down

0 comments on commit 32af8af

Please sign in to comment.