// DBStats contains database statistics.typeDBStatsstruct{MaxOpenConnectionsint// Maximum number of open connections to the database.// Pool StatusOpenConnectionsint// The number of established connections both in use and idle.InUseint// The number of connections currently in use.Idleint// The number of idle connections.// CountersWaitCountint64// The total number of connections waited for.WaitDurationtime.Duration// The total time blocked waiting for a new connection.MaxIdleClosedint64// The total number of connections closed due to SetMaxIdleConns.MaxIdleTimeClosedint64// The total number of connections closed due to SetConnMaxIdleTime.MaxLifetimeClosedint64// The total number of connections closed due to SetConnMaxLifetime.}
// Get generic database object sql.DB to use its functions
sqlDB, err := db.DB()
// SetMaxIdleConns sets the maximum number of connections in the idle connection
pool.sqlDB.SetMaxIdleConns(10)
// SetMaxOpenConns sets the maximum number of open connections to the
database.sqlDB.SetMaxOpenConns(100)
// SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
sqlDB.SetConnMaxLifetime(time.Hour)
var db := &gorm.DB{}
db.Transaction(func(tx *gorm.DB) error {
db.Where("~~~").Find(&Something{})
})