xorm_ext

package module
v0.21.11 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: GPL-3.0 Imports: 9 Imported by: 1

README

xorm_ext

txorm is a tool to connect to mysql, base on github.com/go-xorm/xorm

database(mysql)

Documentation

Index

Constants

View Source
const (
	Logic = iota
	BeforeLogic
	AfterLogic
	OnError
	AfterCommit
)

Function Flags

View Source
const (
	DefaultDatabase = "iTrellis::txorm::default"
)

defines

Variables

View Source
var (
	ErrNotFoundDefaultDatabase    = errors.New("not found default database")
	ErrAtLeastOneRepo             = errors.New("input one repo at least")
	ErrNotFoundTransationFunction = errors.New("not found transation function")
	ErrStructCombineWithRepo      = errors.New("your repository struct should combine repo")
	ErrFailToCreateRepo           = errors.New("fail to create an new repo")
	ErrFailToConvetTXToNonTX      = errors.New("could not convert TX to NON-TX")
	ErrTransactionIsAlreadyBegin  = errors.New("transaction is already begin")
	ErrNonTransactionCantCommit   = errors.New("non-transaction can't commit")
	ErrTransactionSessionIsNil    = errors.New("transaction session is nil")
	ErrNotFoundXormEngine         = errors.New("not found xorm engine")
)

define connector errors

Functions

func AddErrorTypes

func AddErrorTypes(errType reflect.Type)

AddErrorTypes 增加支持的错误类型

func CallFunc

func CallFunc(fn interface{}, funcs LogicFuncs, args []interface{}) ([]interface{}, error)

CallFunc execute transaction function with logic functions and args

func DeepFields

func DeepFields(iface interface{}, vType reflect.Type, fields []reflect.Value) interface{}

DeepFields relect interface deep fields

func Derive

func Derive(origin interface{}) (interface{}, error)

Derive derive from developer function

func GetMysqlDSNFromConfig

func GetMysqlDSNFromConfig(name string, conf config.Config) string

GetMysqlDSNFromConfig get mysql dsn from gogap config

func Inherit

func Inherit(new, origin interface{}) error

Inherit inherit a new repository from origin repository

func NewEnginesFromConfig

func NewEnginesFromConfig(conf config.Config) (engines map[string]*xorm.Engine, err error)

NewEnginesFromConfig initial xorm engine from config

func NewEnginesFromFile

func NewEnginesFromFile(file string) (map[string]*xorm.Engine, error)

NewEnginesFromFile initial xorm engine from file

Types

type Committer

type Committer interface {
	TX(fn interface{}, repos ...interface{}) error
	TXWithName(fn interface{}, name string, repos ...interface{}) error
	NonTX(fn interface{}, repos ...interface{}) error
	NonTXWithName(fn interface{}, name string, repos ...interface{}) error
}

Committer Defination

func New

func New() Committer

New get trellis xorm committer

func NewCommitter

func NewCommitter() Committer

NewCommitter get trellis gorm committer

type Deriver

type Deriver interface {
	Derive() (repo interface{}, err error)
}

Deriver derive function

type Inheritor

type Inheritor interface {
	Inherit(repo interface{}) error
}

Inheritor inherit function

type LogicFuncs

type LogicFuncs struct {
	BeforeLogic interface{}
	AfterLogic  interface{}
	OnError     interface{}
	Logic       interface{}
	AfterCommit interface{}
}

LogicFuncs logic functions

func GetLogicFuncs

func GetLogicFuncs(fn interface{}) (funcs LogicFuncs)

GetLogicFuncs reflect logic function

type TXFunc

type TXFunc func(repos []interface{}) error

TXFunc Transation function

type TXorm

type TXorm struct {
	// contains filtered or unexported fields
}

TXorm trellis xorm

func (*TXorm) NonTX

func (p *TXorm) NonTX(fn interface{}, repos ...interface{}) error

NonTX do non transaction function by default database

func (*TXorm) NonTXWithName

func (p *TXorm) NonTXWithName(fn interface{}, name string, repos ...interface{}) error

NonTXWithName do non transaction function with name of database

func (*TXorm) Session

func (p *TXorm) Session() *xorm.Session

Session get session

func (*TXorm) SetEngines

func (p *TXorm) SetEngines(engines map[string]*xorm.Engine)

SetEngines set xorm engines

func (*TXorm) TX

func (p *TXorm) TX(fn interface{}, repos ...interface{}) error

TX do transaction function by default database

func (*TXorm) TXWithName

func (p *TXorm) TXWithName(fn interface{}, name string, repos ...interface{}) error

TXWithName do transaction function with name of database

Jump to

Keyboard shortcuts

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