Documentation ¶
Index ¶
- Constants
- Variables
- func AddErrorTypes(errType reflect.Type)
- func CallFunc(input interface{}, args ...interface{}) ([]interface{}, error)
- func DeepFields(iface interface{}, vType reflect.Type, fields []reflect.Value) interface{}
- func Derive(origin interface{}) (interface{}, error)
- func Get(session *xorm.Session, bean interface{}, opts ...GetOption) (bool, error)
- func GetMysqlDSNFromConfig(name string, conf config.Config) string
- func Inherit(new, origin interface{}) error
- func InsertMulti(session *xorm.Session, ones interface{}, stepNum int) (int64, error)
- func NewEnginesFromConfig(conf config.Config) (engines map[string]*xorm.Engine, err error)
- func NewEnginesFromDSN(driver, dsn string) (*xorm.Engine, error)
- func NewEnginesFromFile(file string) (map[string]*xorm.Engine, error)
- func TransactionDo(engine xorm.Engine, fn func(*xorm.Session) error) (err error)
- func Update(session *xorm.Session, bean interface{}, opts ...UpdateOption) (int64, error)
- type Committer
- type Derivative
- type GetOption
- type GetOptions
- type Inheritor
- type LogicFunc
- type Repo
- type TXFunc
- type Transaction
- type UpdateOption
- type UpdateOptions
Constants ¶
const ( Logic = iota BeforeLogic AfterLogic OnError AfterCommit )
Function Flags
Variables ¶
var ( ErrNotFoundDefaultDatabase = errcode.New("not found default database") ErrAtLeastOneRepo = errcode.New("input one repo at least") ErrNotFoundTransactionFunction = errcode.New("not found transaction function") ErrStructCombineWithRepo = errcode.New("your repository struct should combine repo") ErrFailToCreateRepo = errcode.New("fail to create an new repo") ErrFailToConvertTXToNonTX = errcode.New("could not convert TX to NON-TX") ErrTransactionIsAlreadyBegin = errcode.New("transaction is already begin") ErrNonTransactionCantCommit = errcode.New("non-transaction can't commit") ErrTransactionSessionIsNil = errcode.New("transaction session is nil") ErrNotFoundXormEngine = errcode.New("not found xorm engine") )
define connector errors
var (
DefaultDatabase = common.FormatNamespaceString("xorm_ext:database")
)
DefaultDatabase default database key
Functions ¶
func CallFunc ¶
func CallFunc(input interface{}, args ...interface{}) ([]interface{}, error)
CallFunc execute transaction function with logic functions and args
func DeepFields ¶
DeepFields reflect interface deep fields
func Derive ¶
func Derive(origin interface{}) (interface{}, error)
Derive derive from developer function
func GetMysqlDSNFromConfig ¶
GetMysqlDSNFromConfig get mysql dsn from gogap config
func Inherit ¶
func Inherit(new, origin interface{}) error
Inherit new repository from origin repository
func InsertMulti ¶
InsertMulti insert multi seperated data in a big data for every step
func NewEnginesFromConfig ¶
NewEnginesFromConfig initial xorm engine from config
func NewEnginesFromDSN ¶
NewEnginesFromDSN initial xorm engine by dsn
func NewEnginesFromFile ¶
NewEnginesFromFile initial xorm engine from file
func TransactionDo ¶
TransactionDo to do transaction with customer function
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 事务处理者
type Derivative ¶
type Derivative interface {
Derive() (repo interface{}, err error)
}
Derivative derive function
type GetOptions ¶
type Inheritor ¶
type Inheritor interface {
Inherit(repo interface{}) error
}
Inheritor inherit function
type LogicFunc ¶
type LogicFunc struct { BeforeLogic interface{} AfterLogic interface{} OnError interface{} Logic interface{} AfterCommit interface{} }
LogicFunc logic functions
func GetLogicFunc ¶
func GetLogicFunc(input interface{}) *LogicFunc
GetLogicFunc reflect logic function
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo trellis xorm
func (*Repo) BeginNonTransaction ¶
func (*Repo) BeginTransaction ¶
type Transaction ¶
type Transaction interface { SetEngines(engines map[string]*xorm.Engine) Session() *xorm.Session BeginTransaction(name string) error BeginNonTransaction(name string) error }
Transaction 事务处理对象 TODO: Engines 为一个option,可以支持redis等
type UpdateOption ¶
type UpdateOption func(*UpdateOptions)
func UpdateArgs ¶
func UpdateArgs(args ...interface{}) UpdateOption
func UpdateCols ¶
func UpdateCols(cols ...string) UpdateOption
func UpdateWheres ¶
func UpdateWheres(wheres interface{}) UpdateOption
type UpdateOptions ¶
type UpdateOptions struct { Wheres interface{} Args []interface{} Cols []string }