Documentation ¶
Index ¶
- func NewXormSession() repository.DbSession
- type LowerMapper
- type XormSession
- func (this *XormSession) Begin() error
- func (this *XormSession) Close() error
- func (this *XormSession) Commit() error
- func (this *XormSession) Complex(qb *repository.QueryBuilder, dest []interface{}) error
- func (this *XormSession) Count(bean interface{}, conds string, params ...interface{}) (int64, error)
- func (this *XormSession) Delete(md interface{}, conds string, params ...interface{}) (int64, error)
- func (this *XormSession) Exec(clause string, params ...interface{}) (sql.Result, error)
- func (this *XormSession) Find(rowsSlicePtr interface{}, md interface{}, orderby string, from int, limit int, ...) error
- func (this *XormSession) Get(dest interface{}, locked bool, orderby string, conds string, ...) (bool, error)
- func (this *XormSession) Insert(mds ...interface{}) (int64, error)
- func (this *XormSession) Query(clause string, params ...interface{}) ([]map[string][]byte, error)
- func (this *XormSession) Rollback() error
- func (this *XormSession) Scan(dest interface{}) (*XormSession, error)
- func (this *XormSession) Sync(bean ...interface{}) error
- func (this *XormSession) Transaction(fc func(s repository.DbSession) error) error
- func (this *XormSession) Update(md interface{}, columns []string, conds string, params ...interface{}) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewXormSession ¶
func NewXormSession() repository.DbSession
Types ¶
type LowerMapper ¶
type LowerMapper struct { }
LowerMapper implements IMapper and provides lower name between struct and database table
func (LowerMapper) Obj2Table ¶
func (m LowerMapper) Obj2Table(o string) string
func (LowerMapper) Table2Obj ¶
func (m LowerMapper) Table2Obj(t string) string
type XormSession ¶
func (*XormSession) Begin ¶
func (this *XormSession) Begin() error
func (*XormSession) Close ¶
func (this *XormSession) Close() error
func (*XormSession) Commit ¶
func (this *XormSession) Commit() error
func (*XormSession) Complex ¶
func (this *XormSession) Complex(qb *repository.QueryBuilder, dest []interface{}) error
func (*XormSession) Count ¶
func (this *XormSession) Count(bean interface{}, conds string, params ...interface{}) (int64, error)
func (*XormSession) Delete ¶
func (this *XormSession) Delete(md interface{}, conds string, params ...interface{}) (int64, error)
第一个参数是删除的数据数组,当传入的为结构体指针时,非空和0的field会被作为删除的条件 不支持指定this.Session.Table(new(User))来指定表名,而是通过结构数组来指定,因此不支持map删除 在数据没有Id的时候,使用第二个参数作为条件
func (*XormSession) Exec ¶
func (this *XormSession) Exec(clause string, params ...interface{}) (sql.Result, error)
execute sql and get result
func (*XormSession) Find ¶
func (this *XormSession) Find(rowsSlicePtr interface{}, md interface{}, orderby string, from int, limit int, conds string, params ...interface{}) error
Find retrieve records from table, condiBeans's non-empty fields are conditions. beans could be []Struct, []*Struct, map[int64]Struct map[int64]*Struct everyone := make([]Userinfo, 0) err := engine.Find(&everyone)
func (*XormSession) Get ¶
func (this *XormSession) Get(dest interface{}, locked bool, orderby string, conds string, params ...interface{}) (bool, error)
Get retrieve one record from database, bean's non-empty fields will be as conditions
func (*XormSession) Insert ¶
func (this *XormSession) Insert(mds ...interface{}) (int64, error)
insert model data to database
func (*XormSession) Query ¶
func (this *XormSession) Query(clause string, params ...interface{}) ([]map[string][]byte, error)
execute sql and get result
func (*XormSession) Rollback ¶
func (this *XormSession) Rollback() error
func (*XormSession) Scan ¶
func (this *XormSession) Scan(dest interface{}) (*XormSession, error)
scan result
func (*XormSession) Sync ¶
func (this *XormSession) Sync(bean ...interface{}) error
func (*XormSession) Transaction ¶
func (this *XormSession) Transaction(fc func(s repository.DbSession) error) error
*
Transaction 的 f 参数类型为 一个在事务内处理的函数 因此可以将 f 函数作为参数传入 Transaction 函数中。 return Transaction(func(s *XormSession) error { if _,error := session.Insert(User{ID:5,Version:"abc"}); error != nil{ return error } })
func (*XormSession) Update ¶
func (this *XormSession) Update(md interface{}, columns []string, conds string, params ...interface{}) (int64, error)
第一个参数是更新的数据数组,当传入的为结构体指针时,只有非空和0的field才会被作为更新的字段 第二个参数指定要被更新的字段名称,即使非空和0的field也会被更新 不支持指定this.Session.Table(new(User))来指定表名,而是通过结构数组来指定,因此不支持map更新 在数据没有Id的时候,使用第三个参数条件bean作为条件