mysql

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 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 transaction

func (*Xorm) TransactionWithSession

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

TransactionWithSession support transaction nested if tx is started, sess will not commit

Jump to

Keyboard shortcuts

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