cDB

package module
v0.4.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DatabaseConfigName = "DatabaseConf"
)

Variables

View Source
var Component = &DBComponent{}

Functions

func AddConnection added in v0.4.0

func AddConnection(ctx *gin.Context, name string, connection drivers.DriverInterface) error

func Client added in v0.4.6

func Client[T DBClient](ctx *gin.Context, name string) T

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 DBClient added in v0.4.8

type DBClient interface {
	*gorm.DB | *redis.Client | *mgo.Database
}

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

type ModelInterface interface {
	Connection(ctx *gin.Context) string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL