Documentation
¶
Index ¶
- func GetSeq(name string, count int) []uint64
- func GetSeqValue(name string) (uint64, error)
- func GetSession() repository.DbSession
- func PlaceQuestionMark(n int) string
- func RegistSeq(name string, increment uint64)
- type BaseService
- type OrmBaseService
- func (this *OrmBaseService) BatchInsert(mds ...interface{}) (int64, error)
- func (this *OrmBaseService) Count(bean interface{}, conds string, params ...interface{}) (int64, error)
- func (this *OrmBaseService) Delete(md interface{}, conds string, params ...interface{}) (int64, error)
- func (this *OrmBaseService) Exec(clause string, params ...interface{}) (sql.Result, error)
- func (this *OrmBaseService) Export(condiBean interface{}) ([]byte, error)
- func (this *OrmBaseService) Find(rowsSlicePtr interface{}, condiBean interface{}, orderby string, from int, ...) error
- func (this *OrmBaseService) Get(dest interface{}, locked bool, orderby string, conds string, ...) (bool, error)
- func (this *OrmBaseService) GetSeq() uint64
- func (this *OrmBaseService) GetSeqs(count int) []uint64
- func (this *OrmBaseService) Import(filenames []string) error
- func (this *OrmBaseService) Insert(mds ...interface{}) (int64, error)
- func (this *OrmBaseService) NewEntities(data []byte) (interface{}, error)
- func (this *OrmBaseService) NewEntity(data []byte) (interface{}, error)
- func (this *OrmBaseService) ParseJSON(data []byte) ([]interface{}, error)
- func (this *OrmBaseService) Query(clause string, params ...interface{}) ([]map[string][]byte, error)
- func (this *OrmBaseService) Save(mds ...interface{}) (int64, error)
- func (this *OrmBaseService) Transaction(fc func(s repository.DbSession) (interface{}, error)) (interface{}, error)
- func (this *OrmBaseService) Update(md interface{}, columns []string, conds string, params ...interface{}) (int64, error)
- func (this *OrmBaseService) Upsert(mds ...interface{}) (int64, error)
- type SeqCache
- type SequenceService
- func (this *SequenceService) CreateSeq(name string, increment uint64, minValue uint64) int64
- func (this *SequenceService) GetSeqName() string
- func (this *SequenceService) GetSeqValue(name string) (uint64, error)
- func (this *SequenceService) NewEntities(data []byte) (interface{}, error)
- func (this *SequenceService) NewEntity(data []byte) (interface{}, error)
- type SessionDataService
- type SessionService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSeqValue ¶
func GetSession ¶
func GetSession() repository.DbSession
func PlaceQuestionMark ¶
Types ¶
type BaseService ¶
type BaseService interface {
GetSeq() uint64
GetSeqs(count int) []uint64
NewEntity(data []byte) (interface{}, error)
//返回数组的指针
NewEntities(data []byte) (interface{}, error)
ParseJSON(data []byte) ([]interface{}, error)
Get(dest interface{}, locked bool, orderby string, conds string, params ...interface{}) (bool, error)
Find(rowsSlicePtr interface{}, md interface{}, orderby string, from int, limit int, conds string, params ...interface{}) error
Insert(mds ...interface{}) (int64, error)
BatchInsert(mds ...interface{}) (int64, error)
Update(md interface{}, columns []string, conds string, params ...interface{}) (int64, error)
Upsert(mds ...interface{}) (int64, error)
Delete(md interface{}, conds string, params ...interface{}) (int64, error)
Save(mds ...interface{}) (int64, error)
Exec(clause string, params ...interface{}) (sql.Result, error)
Query(clause string, params ...interface{}) ([]map[string][]byte, error)
Count(bean interface{}, conds string, params ...interface{}) (int64, error)
Transaction(fc func(s repository.DbSession) (interface{}, error)) (interface{}, error)
}
func GetOrmBaseService ¶
func GetOrmBaseService() BaseService
type OrmBaseService ¶
type OrmBaseService struct {
GetSeqName func() string
FactNewEntity func(data []byte) (interface{}, error)
FactNewEntities func(data []byte) (interface{}, error)
}
func (*OrmBaseService) BatchInsert ¶ added in v0.1.16
func (this *OrmBaseService) BatchInsert(mds ...interface{}) (int64, error)
func (*OrmBaseService) Count ¶
func (this *OrmBaseService) Count(bean interface{}, conds string, params ...interface{}) (int64, error)
func (*OrmBaseService) Delete ¶
func (this *OrmBaseService) Delete(md interface{}, conds string, params ...interface{}) (int64, error)
delete model in database Delete records, bean's non-empty fields are conditions
func (*OrmBaseService) Exec ¶
func (this *OrmBaseService) Exec(clause string, params ...interface{}) (sql.Result, error)
execute sql and get result
func (*OrmBaseService) Export ¶
func (this *OrmBaseService) Export(condiBean interface{}) ([]byte, error)
func (*OrmBaseService) Find ¶
func (this *OrmBaseService) Find(rowsSlicePtr interface{}, condiBean 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 (*OrmBaseService) Get ¶
func (this *OrmBaseService) 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 (*OrmBaseService) GetSeq ¶
func (this *OrmBaseService) GetSeq() uint64
func (*OrmBaseService) GetSeqs ¶
func (this *OrmBaseService) GetSeqs(count int) []uint64
func (*OrmBaseService) Import ¶
func (this *OrmBaseService) Import(filenames []string) error
* 导入excel格式的数据
func (*OrmBaseService) Insert ¶
func (this *OrmBaseService) Insert(mds ...interface{}) (int64, error)
insert model data to database
func (*OrmBaseService) NewEntities ¶
func (this *OrmBaseService) NewEntities(data []byte) (interface{}, error)
func (*OrmBaseService) NewEntity ¶
func (this *OrmBaseService) NewEntity(data []byte) (interface{}, error)
func (*OrmBaseService) ParseJSON ¶
func (this *OrmBaseService) ParseJSON(data []byte) ([]interface{}, error)
func (*OrmBaseService) Query ¶
func (this *OrmBaseService) Query(clause string, params ...interface{}) ([]map[string][]byte, error)
execute sql and get result
func (*OrmBaseService) Save ¶
func (this *OrmBaseService) Save(mds ...interface{}) (int64, error)
save model data to database by state field
func (*OrmBaseService) Transaction ¶
func (this *OrmBaseService) Transaction(fc func(s repository.DbSession) (interface{}, error)) (interface{}, error)
*
Transaction 的 f 参数类型为 一个在事务内处理的函数
因此可以将 f 函数作为参数传入 Transaction 函数中。
return Transaction(func(s *BaseService) error {
if _,error := session.Insert(User{ID:5,Version:"abc"}); error != nil{
return error
}
})
func (*OrmBaseService) Update ¶
func (this *OrmBaseService) Update(md interface{}, columns []string, conds string, params ...interface{}) (int64, error)
update model to database. cols set the columns those want to update.
func (*OrmBaseService) Upsert ¶
func (this *OrmBaseService) Upsert(mds ...interface{}) (int64, error)
Upsert model data to database by id field
type SequenceService ¶
type SequenceService struct {
OrmBaseService
}
func GetSequenceService ¶
func GetSequenceService() *SequenceService
func (*SequenceService) CreateSeq ¶
func (this *SequenceService) CreateSeq(name string, increment uint64, minValue uint64) int64
func (*SequenceService) GetSeqName ¶
func (this *SequenceService) GetSeqName() string
func (*SequenceService) GetSeqValue ¶
func (this *SequenceService) GetSeqValue(name string) (uint64, error)
func (*SequenceService) NewEntities ¶
func (this *SequenceService) NewEntities(data []byte) (interface{}, error)
func (*SequenceService) NewEntity ¶
func (this *SequenceService) NewEntity(data []byte) (interface{}, error)
type SessionDataService ¶
type SessionDataService struct {
OrmBaseService
}
func GetSessionDataService ¶
func GetSessionDataService() *SessionDataService
func (*SessionDataService) GetSeqName ¶
func (this *SessionDataService) GetSeqName() string
type SessionService ¶
type SessionService struct {
OrmBaseService
}
func GetSessionService ¶
func GetSessionService() *SessionService
func (*SessionService) GetSeqName ¶
func (this *SessionService) GetSeqName() string
func (*SessionService) NewEntities ¶
func (this *SessionService) NewEntities(data []byte) (interface{}, error)
func (*SessionService) NewEntity ¶
func (this *SessionService) NewEntity(data []byte) (interface{}, error)
Click to show internal directories.
Click to hide internal directories.