Documentation
¶
Index ¶
- Variables
- func AddConnection(ctx *gin.Context, name string, connection DriverInterface) error
- func WithConnectionModel(ctx *gin.Context, model ModelInterface, name string) *gorm.DB
- func WithContextModel(ctx *gin.Context, model ModelInterface) *gorm.DB
- type ConnectorInterface
- type DBComponent
- type DBContainer
- type DBDriver
- type DatabaseConf
- type DatabaseConf_MySql
- type DatabaseConf_MySql_HealthCheck
- type DatabaseConf_MySql_Pool
- type DatabaseConf_Sqlite
- type DriverInterface
- type ModelInterface
- type MysqlConnector
- type QueryDB
- type SqliteConnector
Constants ¶
This section is empty.
Variables ¶
View Source
var Component = &DBComponent{}
Functions ¶
func AddConnection ¶ added in v0.4.0
func AddConnection(ctx *gin.Context, name string, connection DriverInterface) error
func WithConnectionModel ¶ added in v0.0.52
func WithContextModel ¶ added in v0.0.52
func WithContextModel(ctx *gin.Context, model ModelInterface) *gorm.DB
Types ¶
type ConnectorInterface ¶
type ConnectorInterface interface { GetConnection() string GetDriver() DriverInterface GetDB() *gorm.DB Connect() error }
type DBComponent ¶ added in v0.3.2
type DBComponent struct{}
func (*DBComponent) Inject ¶ added in v0.3.2
func (i *DBComponent) Inject(instance any) bool
func (*DBComponent) InjectConf ¶ added in v0.4.0
func (i *DBComponent) InjectConf(config cComponents.ConfigInterface) bool
func (*DBComponent) Listen ¶ added in v0.4.0
func (i *DBComponent) Listen() []*cComponents.ConfigListener
func (*DBComponent) Load ¶ added in v0.3.2
func (i *DBComponent) Load()
type DBContainer ¶ added in v0.4.0
type DBContainer struct {
// contains filtered or unexported fields
}
func (*DBContainer) Get ¶ added in v0.4.0
func (i *DBContainer) Get(name string) any
func (*DBContainer) GetConnector ¶ added in v0.4.0
func (i *DBContainer) GetConnector(name string) ConnectorInterface
func (*DBContainer) Is ¶ added in v0.4.0
func (i *DBContainer) Is(instance any) bool
func (*DBContainer) Range ¶ added in v0.4.0
func (i *DBContainer) Range(f func(instance any))
func (*DBContainer) Remove ¶ added in v0.4.0
func (i *DBContainer) Remove(name string) bool
func (*DBContainer) Save ¶ added in v0.4.0
func (i *DBContainer) Save(instance any) bool
type DatabaseConf ¶
type DatabaseConf struct { MysqlConnections map[string]*DatabaseConf_MySql `json:"mysql_connections"` SqliteConnections map[string]*DatabaseConf_Sqlite `json:"sqlite_connections"` }
func (*DatabaseConf) ConfigName ¶
func (i *DatabaseConf) ConfigName() string
type DatabaseConf_MySql ¶
type DatabaseConf_MySql struct { Driver DBDriver `json:"driver"` Host string `json:"host"` Port int `json:"port"` Database string `json:"database"` Username string `json:"username"` Password string `json:"password"` Charset string `json:"charset"` Collation string `json:"collation"` Prefix string `json:"prefix"` Debug bool `json:"debug"` Pool *DatabaseConf_MySql_Pool `json:"pool"` HealthCheck *DatabaseConf_MySql_HealthCheck `json:"health_check"` }
func (*DatabaseConf_MySql) DriverName ¶ added in v0.4.0
func (i *DatabaseConf_MySql) DriverName() DBDriver
func (*DatabaseConf_MySql) IsDebug ¶ added in v0.4.0
func (i *DatabaseConf_MySql) IsDebug() bool
type DatabaseConf_MySql_Pool ¶
type DatabaseConf_Sqlite ¶ added in v0.4.0
type DatabaseConf_Sqlite struct { Driver DBDriver `json:"driver"` File string `json:"file"` Debug bool `json:"debug"` }
func (*DatabaseConf_Sqlite) DriverName ¶ added in v0.4.0
func (i *DatabaseConf_Sqlite) DriverName() DBDriver
func (*DatabaseConf_Sqlite) IsDebug ¶ added in v0.4.0
func (i *DatabaseConf_Sqlite) IsDebug() bool
type DriverInterface ¶ added in v0.4.0
type ModelInterface ¶
type MysqlConnector ¶
type MysqlConnector struct {
// contains filtered or unexported fields
}
func NewMysqlConnector ¶ added in v0.4.0
func NewMysqlConnector(connection string, config *DatabaseConf_MySql) (*MysqlConnector, error)
func (*MysqlConnector) Connect ¶
func (i *MysqlConnector) Connect() error
func (*MysqlConnector) GetConnection ¶ added in v0.4.0
func (i *MysqlConnector) GetConnection() string
func (*MysqlConnector) GetDB ¶ added in v0.4.0
func (i *MysqlConnector) GetDB() *gorm.DB
func (*MysqlConnector) GetDriver ¶ added in v0.4.0
func (i *MysqlConnector) GetDriver() DriverInterface
type QueryDB ¶ added in v0.4.0
type QueryDB struct {
// contains filtered or unexported fields
}
func WithQueryModel ¶ added in v0.4.0
func WithQueryModel(ctx *gin.Context, model ModelInterface) *QueryDB
type SqliteConnector ¶ added in v0.4.0
type SqliteConnector struct {
// contains filtered or unexported fields
}
func NewSqliteConnector ¶ added in v0.4.0
func NewSqliteConnector(connection string, config *DatabaseConf_Sqlite) (*SqliteConnector, error)
func (*SqliteConnector) Connect ¶ added in v0.4.0
func (i *SqliteConnector) Connect() error
func (*SqliteConnector) GetConnection ¶ added in v0.4.0
func (i *SqliteConnector) GetConnection() string
func (*SqliteConnector) GetDB ¶ added in v0.4.0
func (i *SqliteConnector) GetDB() *gorm.DB
func (*SqliteConnector) GetDriver ¶ added in v0.4.0
func (i *SqliteConnector) GetDriver() DriverInterface
Click to show internal directories.
Click to hide internal directories.