Documentation ¶
Index ¶
- Constants
- Variables
- func AddConnection(ctx *gin.Context, name string, connection drivers.DriverInterface) error
- func Client[T DBClient](ctx *gin.Context, name string) T
- func WithContextModel(ctx *gin.Context, model ModelInterface) *gorm.DB
- func WithQueryModel(ctx *gin.Context, model ModelInterface) drivers.GormQueryInterface
- type DBClient
- type DBComponent
- type DBContainer
- func (i *DBContainer) Get(name string) any
- func (i *DBContainer) GetConnector(name string) drivers.ConnectorInterface
- func (i *DBContainer) Is(instance any) bool
- func (i *DBContainer) Range(f func(instance any))
- func (i *DBContainer) Remove(name string) bool
- func (i *DBContainer) Save(instance any) bool
- type DatabaseConf
- type ModelInterface
Constants ¶
View Source
const (
DatabaseConfigName = "DatabaseConf"
)
Variables ¶
View Source
var Component = &DBComponent{}
Functions ¶
func AddConnection ¶ added in v0.4.0
func WithContextModel ¶ added in v0.0.52
func WithContextModel(ctx *gin.Context, model ModelInterface) *gorm.DB
WithContextModel 仅用于 gorm
func WithQueryModel ¶ added in v0.4.0
func WithQueryModel(ctx *gin.Context, model ModelInterface) drivers.GormQueryInterface
Types ¶
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) drivers.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 {
Connections map[string]drivers.DriverInterface `json:"connections"`
}
func (*DatabaseConf) ConfigName ¶
func (i *DatabaseConf) ConfigName() string
func (*DatabaseConf) Decode ¶ added in v0.4.8
func (i *DatabaseConf) Decode(data string) error
type ModelInterface ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.