Documentation
¶
Overview ¶
Package database is a package for managing database drivers.
Index ¶
- func Connect(driverName string, options map[string]any) (*gorm.DB, error)
- func Drivers() []string
- func ExpandSliceWithEnvHook(f reflect.Type, _ reflect.Type, data any) (any, error)
- func ExpandStringKeyMapWithEnvHook(f reflect.Type, _ reflect.Type, data any) (any, error)
- func NamingStrategyParseHookFunc() func(f reflect.Type, t reflect.Type, data any) (any, error)
- func Open(driverName string, options map[string]any) (gorm.Dialector, error)
- func Register(driverName string, driver database.Driver)
- func StringToLocationHookFunc() func(f reflect.Type, t reflect.Type, data any) (any, error)
- type DatabaseManager
- func (m *DatabaseManager) AddConnection(name string, db *gorm.DB)
- func (m *DatabaseManager) AddDeferConnection(name string, config map[string]any)
- func (m *DatabaseManager) GetConnection(name string) *gorm.DB
- func (m *DatabaseManager) HasConnection(name string) bool
- func (m *DatabaseManager) SetDefaultConnection(connection string)
- type DuplicateConnectionException
- type NotConfiguredException
- type UnregisteredDriverException
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandSliceWithEnvHook ¶
func Open ¶
Open opens a new database connector using the given driver name and options. If the driver with the given name doesn't exist, it panics.
Types ¶
type DatabaseManager ¶
func NewDatabaseManager ¶
func NewDatabaseManager() *DatabaseManager
func (*DatabaseManager) AddConnection ¶
func (m *DatabaseManager) AddConnection(name string, db *gorm.DB)
func (*DatabaseManager) AddDeferConnection ¶
func (m *DatabaseManager) AddDeferConnection(name string, config map[string]any)
func (*DatabaseManager) GetConnection ¶
func (m *DatabaseManager) GetConnection(name string) *gorm.DB
func (*DatabaseManager) HasConnection ¶
func (m *DatabaseManager) HasConnection(name string) bool
func (*DatabaseManager) SetDefaultConnection ¶
func (m *DatabaseManager) SetDefaultConnection(connection string)
type DuplicateConnectionException ¶
type DuplicateConnectionException struct {
Throwable
}
func NewDuplicateDriverException ¶
func NewDuplicateDriverException(name string) *DuplicateConnectionException
type NotConfiguredException ¶
type NotConfiguredException struct {
Throwable
}
func NewNotConfiguredException ¶
func NewNotConfiguredException(name string) *NotConfiguredException
type UnregisteredDriverException ¶
type UnregisteredDriverException struct {
Throwable
}
func NewUnregisteredDriverException ¶
func NewUnregisteredDriverException(name string) *UnregisteredDriverException
Click to show internal directories.
Click to hide internal directories.