mysql

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ShowSQL         bool `defval:"true"`
	Master          Conn
	Slaves          []Conn
	MaxOpenConn     int  `defval:"50"`
	MaxIdleConn     int  `defval:"200"`
	ConnMaxLifetime uint `defval:"7200"` // sec 空闲连接最大生命周期
}

type Conn

type Conn struct {
	Username string `defval:"root"`
	Password string `defval:"111111" null:""`
	HostPort string `defval:"localhost:3306"`
	Database string `defval:"test"`
}

type ORM

type ORM interface {
	xorm.EngineInterface
}

type Xorm

type Xorm struct {
	*xorm.EngineGroup
}

func NewXorm

func NewXorm(cfg Config) *Xorm

NewXorm EngineGroup

func (*Xorm) Transaction

func (x *Xorm) Transaction(tx func(sess *xorm.Session) error) error

Transaction Master 事务

func (*Xorm) TransactionWithSession

func (x *Xorm) TransactionWithSession(sess *xorm.Session, tx func(sess *xorm.Session) error) error

TransactionWithSession 支持事务嵌套,如果事务已经开始,则此事务失效事务的步骤 传入的 session 可以是Master/Slave/上层传入

Jump to

Keyboard shortcuts

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