Documentation ¶
Overview ¶
Package db database plugin based on xorm.
Index ¶
- func Transaction(ctx context.Context, handlers ...TransactionHandler) error
- func TransactionWithSession(ctx context.Context, sess *xorm.Session, handlers ...TransactionHandler) (err error)
- type Configuration
- type Connection
- func (o *Connection) GetEngineGroup(keys ...string) (engine *xorm.EngineGroup)
- func (o *Connection) GetMaster(keys ...string) *xorm.Session
- func (o *Connection) GetMasterWithContext(ctx context.Context, keys ...string) *xorm.Session
- func (o *Connection) GetSlave(keys ...string) *xorm.Session
- func (o *Connection) GetSlaveWithContext(ctx context.Context, keys ...string) *xorm.Session
- type Database
- type Service
- type TransactionHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Transaction ¶
func Transaction(ctx context.Context, handlers ...TransactionHandler) error
func TransactionWithSession ¶
Types ¶
type Configuration ¶
type Configuration struct { Databases map[string]*Database `yaml:"databases"` // contains filtered or unexported fields }
var Config *Configuration
func (*Configuration) GetDatabase ¶
func (o *Configuration) GetDatabase(key string) *Database
func (*Configuration) GetDefault ¶
func (o *Configuration) GetDefault() *Database
func (*Configuration) SetDatabase ¶
func (o *Configuration) SetDatabase(key string, database *Database)
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
var Connector *Connection
func (*Connection) GetEngineGroup ¶
func (o *Connection) GetEngineGroup(keys ...string) (engine *xorm.EngineGroup)
func (*Connection) GetMasterWithContext ¶
func (*Connection) GetSlaveWithContext ¶
type Database ¶
type Database struct { Driver string `yaml:"driver"` Dsn []string `yaml:"dsn"` MaxIdle int `yaml:"max-idle"` MaxLifetime int `yaml:"max-lifetime"` MaxOpen int `yaml:"max-open"` Mapper string `yaml:"mapper"` EnableSession *bool `yaml:"enable-session"` ShowSQL *bool `yaml:"show-sql"` // contains filtered or unexported fields }
func (*Database) GetDataName ¶
func (*Database) GetUsername ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) UseConnection ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.