Documentation ¶
Index ¶
- func RunNoTx(tenant interface{}, fn func(session *Session) error) error
- func RunTx(tenant interface{}, fn func(session *Session) error) error
- func RunWithTenant[T any](s *Session, tenant interface{}, runner func() T) T
- func SetOrmVerbose()
- func ValueToInt(val interface{}) int
- func ValueToInt64(val interface{}) int64
- type Criteria
- func (this *Criteria) AggregateList(s string, r interface{}) *Criteria
- func (this *Criteria) AggregateOne(s string, r interface{}) *Criteria
- func (this *Criteria) And(criteria *Criteria) *Criteria
- func (this *Criteria) AndOr(criteria *Criteria) *Criteria
- func (this *Criteria) AndOrAnd(criteriaSet *CriteriaSet) *Criteria
- func (this *Criteria) Between(path string, value interface{}, value2 interface{}) *Criteria
- func (this *Criteria) CopyConditions(c *Criteria)
- func (this *Criteria) Count() *Criteria
- func (this *Criteria) Delete() *Criteria
- func (this *Criteria) Eq(path string, value interface{}) *Criteria
- func (this *Criteria) EqAnd(path string, value interface{}) *Criteria
- func (this *Criteria) Exists() bool
- func (this *Criteria) Ge(path string, value interface{}) *Criteria
- func (this *Criteria) Get(id int64) *Criteria
- func (this *Criteria) GroupBy(s string) *Criteria
- func (this *Criteria) Gt(path string, value interface{}) *Criteria
- func (this *Criteria) In(path string, values ...interface{}) *Criteria
- func (this *Criteria) IsCount() bool
- func (this *Criteria) IsExists() bool
- func (this *Criteria) IsList() bool
- func (this *Criteria) IsListAndCount() bool
- func (this *Criteria) IsNotNull(path string) *Criteria
- func (this *Criteria) IsNull(path string) *Criteria
- func (this *Criteria) IsOne() bool
- func (this *Criteria) Le(path string, value interface{}) *Criteria
- func (this *Criteria) Like(path string, value interface{}) *Criteria
- func (this *Criteria) LikeMatch(path string, value interface{}, likeMatch CriteriaLikeMatch) *Criteria
- func (this *Criteria) List() *Criteria
- func (this *Criteria) ListAndCount() *Criteria
- func (this *Criteria) Lt(path string, value interface{}) *Criteria
- func (this *Criteria) Ne(path string, value interface{}) *Criteria
- func (this *Criteria) NotIn(path string, values ...interface{}) *Criteria
- func (this *Criteria) NotLike(path string, value interface{}) *Criteria
- func (this *Criteria) NotLikeMatch(path string, value interface{}, likeMatch CriteriaLikeMatch) *Criteria
- func (this *Criteria) One() *Criteria
- func (this *Criteria) Or(criteria *Criteria) *Criteria
- func (this *Criteria) OrAnd(criteria *Criteria) *Criteria
- func (this *Criteria) OrderAsc(path string) *Criteria
- func (this *Criteria) OrderDesc(path string) *Criteria
- func (this *Criteria) Query() orm.QuerySeter
- func (this *Criteria) RunWithTenant(tenant interface{}, runner func(c *Criteria))
- func (this *Criteria) SetDebug(debug bool) *Criteria
- func (this *Criteria) SetDefaults() *Criteria
- func (this *Criteria) SetDistinct() *Criteria
- func (this *Criteria) SetEntity(entity interface{}) *Criteria
- func (this *Criteria) SetError(err error)
- func (this *Criteria) SetLimit(limit int64) *Criteria
- func (this *Criteria) SetOffset(offset int64) *Criteria
- func (this *Criteria) SetPage(page *Page) *Criteria
- func (this *Criteria) SetRelatedSel(related string) *Criteria
- func (this *Criteria) SetRelatedsSel(relateds ...string) *Criteria
- func (this *Criteria) SetResult(result interface{}) *Criteria
- func (this *Criteria) SetResults(results []interface{}) *Criteria
- func (this *Criteria) TryList() interface{}
- func (this *Criteria) TryOne() interface{}
- func (this *Criteria) TryOneById(id int64) interface{}
- func (this *Criteria) Update(args map[string]interface{}) *Criteria
- func (this *Criteria) WithTenant(tenant interface{}) *Criteria
- type CriteriaExpression
- type CriteriaLikeMatch
- type CriteriaOrder
- type CriteriaResult
- type CriteriaSet
- type DataBase
- func (this *DataBase) Begin() (err error)
- func (this *DataBase) BeginWithOpts(opts *sql.TxOptions) (err error)
- func (this *DataBase) Commit() (err error)
- func (this *DataBase) Delete(entity interface{}) (int64, error)
- func (this *DataBase) GetOrmer() orm.Ormer
- func (this *DataBase) GetTxOrmer() orm.TxOrmer
- func (this *DataBase) Insert(entity interface{}) (int64, error)
- func (this *DataBase) InsertMulti(bulk int, entities interface{}) (int64, error)
- func (this *DataBase) LoadRelated(entity interface{}, name string, args ...utils.KV) (int64, error)
- func (this *DataBase) Open()
- func (this *DataBase) QueryM2M(entity interface{}, name string) orm.QueryM2Mer
- func (this *DataBase) QueryTable(ptrStructOrTableName interface{}) orm.QuerySeter
- func (this *DataBase) Raw(query string, args ...interface{}) orm.RawSeter
- func (this *DataBase) Read(entity interface{}, cols ...string) error
- func (this *DataBase) ReadOrCreate(entity interface{}, col string, cols ...string) (bool, int64, error)
- func (this *DataBase) Rollback() (err error)
- func (this *DataBase) Update(entity interface{}, colConflictAndArgs ...string) (int64, error)
- type Model
- type ModelHookAfterList
- type ModelHookAfterLoad
- type ModelHookAfterRemove
- type ModelHookAfterSave
- type ModelHookAfterUpdate
- type ModelHookBeforeCriteria
- type ModelHookBeforeQuery
- type ModelHookBeforeRemove
- type ModelHookBeforeSave
- type ModelHookBeforeUpdate
- type Page
- func (this *Page) AddAndInOrConditionFilter(columnName string, value interface{}) *Page
- func (this *Page) AddFilter(columnName string, value interface{}) *Page
- func (this *Page) AddFilterAnd(columnName string, value interface{}) *Page
- func (this *Page) AddFilterDefault(columnName string) *Page
- func (this *Page) AddFilterDefaults(columnName ...string) *Page
- func (this *Page) MakeDefaultSort()
- type RawQuery
- func (this *RawQuery) Execute() (int64, error)
- func (this *RawQuery) GetValues() []map[string]interface{}
- func (this *RawQuery) GetValuesFlat() []interface{}
- func (this *RawQuery) GetValuesList() [][]interface{}
- func (this *RawQuery) HasError() bool
- func (this *RawQuery) RawSeter() orm.RawSeter
- func (this *RawQuery) ToResutl(result interface{}) error
- func (this *RawQuery) ToResutls(results interface{}) error
- func (this *RawQuery) Values() *RawQuery
- func (this *RawQuery) ValuesFlat() *RawQuery
- func (this *RawQuery) ValuesList() *RawQuery
- func (this *RawQuery) WithArgs(args ...interface{}) *RawQuery
- func (this *RawQuery) WithQuery(query string) *RawQuery
- func (this *RawQuery) WithSession(session *Session) *RawQuery
- type RawQueryTransformer
- func (this *RawQueryTransformer[T]) First() (T, error)
- func (this *RawQueryTransformer[T]) List() ([]T, error)
- func (this *RawQueryTransformer[T]) WithListTransformer(tr func([]interface{}) (T, error)) *RawQueryTransformer[T]
- func (this *RawQueryTransformer[T]) WithValuesTransformer(tr func(map[string]interface{}) (T, error)) *RawQueryTransformer[T]
- type Session
- func (this *Session) Close()
- func (this *Session) Commit() (err error)
- func (this *Session) Count(entity interface{}) (int64, error)
- func (this *Session) Eager(reply interface{}) error
- func (this *Session) EagerForce(reply interface{}) error
- func (this *Session) ExecuteDelete(querySeter orm.QuerySeter) (int64, error)
- func (this *Session) ExecuteUpdate(querySeter orm.QuerySeter, args map[string]interface{}) (int64, error)
- func (this *Session) FindById(entity interface{}, id int64) (interface{}, error)
- func (this *Session) Get(entity interface{}) (bool, error)
- func (this *Session) GetDb() *DataBase
- func (this *Session) HasById(entity interface{}, id int64) (bool, error)
- func (this *Session) HasFilterTenant(reply interface{}) bool
- func (this *Session) HasTenant() bool
- func (this *Session) IsNil(e interface{}) bool
- func (this *Session) IsOpenDbError() bool
- func (this *Session) List(entity interface{}, entities interface{}) error
- func (this *Session) Load(entity interface{}) (bool, error)
- func (this *Session) LoadBatch(entities ...interface{}) error
- func (this *Session) OnError() *Session
- func (this *Session) Open(withTx bool) error
- func (this *Session) OpenNoTx() error
- func (this *Session) OpenOpt() interface{}
- func (this *Session) OpenTx() error
- func (this *Session) OpenTxOpt() interface{}
- func (this *Session) OpenTxWithOpts(opts *sql.TxOptions) error
- func (this *Session) OpenTxWithOptsOpt(opts *sql.TxOptions) interface{}
- func (this *Session) OpenWithTx() error
- func (this *Session) OpenWithTxOpts(opts *sql.TxOptions) error
- func (this *Session) OpenWithoutTx() error
- func (this *Session) Page(entity interface{}, entities interface{}, page *Page) error
- func (this *Session) PageQuery(query orm.QuerySeter, entity interface{}, entities interface{}, page *Page) error
- func (this *Session) Query(entity interface{}) (orm.QuerySeter, error)
- func (this *Session) Remove(entity interface{}) error
- func (this *Session) RemoveCascade(reply interface{}) error
- func (this *Session) RemoveCascadeDeep(reply interface{}, firstTime bool) error
- func (this *Session) Rollback() (err error)
- func (this *Session) RunWithTenant(tenant interface{}, runner func())
- func (this *Session) Save(entity interface{}) error
- func (this *Session) SaveCascade(reply interface{}) error
- func (this *Session) SaveOrUpdate(entity interface{}) error
- func (this *Session) SaveOrUpdateCascade(reply interface{}) error
- func (this *Session) SetAuthorizedTenants(tenants []interface{}) *Session
- func (this *Session) SetCheckAuthorizedTenant() *Session
- func (this *Session) SetDatabase(dt *DataBase) *Session
- func (this *Session) SetDebug() *Session
- func (this *Session) SetDefaults(reply interface{}) error
- func (this *Session) SetError() *Session
- func (this *Session) SetIgnoreTenantFilter() *Session
- func (this *Session) SetNoAuthSession() *Session
- func (this *Session) SetTenant(tenant interface{}) *Session
- func (this *Session) SetUseTenantFilter(s bool) *Session
- func (this *Session) ToCount(querySeter orm.QuerySeter) (int64, error)
- func (this *Session) ToList(querySeter orm.QuerySeter, entities interface{}) error
- func (this *Session) ToOne(querySeter orm.QuerySeter, entity interface{}) error
- func (this *Session) ToPage(querySeter orm.QuerySeter, entities interface{}, page *Page) error
- func (this *Session) TryLoad(entity interface{}) (bool, error)
- func (this *Session) TryLoadBatch(entities ...interface{}) error
- func (this *Session) Update(entity interface{}) error
- func (this *Session) WithTenant(tenant interface{}, runner func() error) error
- func (this *Session) WithTx() (*Session, error)
- func (this *Session) WithTxOpts(opts *sql.TxOptions) (*Session, error)
- func (this *Session) WithoutTx() (*Session, error)
- type SessionState
- type TenantModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunWithTenant ¶
func SetOrmVerbose ¶
func SetOrmVerbose()
func ValueToInt ¶
func ValueToInt(val interface{}) int
func ValueToInt64 ¶
func ValueToInt64(val interface{}) int64
Types ¶
type Criteria ¶
type Criteria struct { Path string Value interface{} Value2 interface{} Expression CriteriaExpression Match CriteriaLikeMatch InValues []interface{} Result interface{} Results interface{} UpdateParams map[string]interface{} Page *Page Error error Count32 int Count64 int64 Limit int64 Offset int64 Session *Session RelatedSelList []string Any bool Empty bool HasError bool ForceAnd bool ForceOr bool Distinct bool Debug bool // contains filtered or unexported fields }
func NewCondition ¶
func NewCondition() *Criteria
func NewCriteria ¶
func (*Criteria) AggregateList ¶
func (*Criteria) AggregateOne ¶
func (*Criteria) AndOrAnd ¶
func (this *Criteria) AndOrAnd(criteriaSet *CriteriaSet) *Criteria
func (*Criteria) CopyConditions ¶
func (*Criteria) IsListAndCount ¶
func (*Criteria) LikeMatch ¶
func (this *Criteria) LikeMatch(path string, value interface{}, likeMatch CriteriaLikeMatch) *Criteria
func (*Criteria) ListAndCount ¶
func (*Criteria) NotLikeMatch ¶
func (this *Criteria) NotLikeMatch(path string, value interface{}, likeMatch CriteriaLikeMatch) *Criteria
func (*Criteria) Query ¶
func (this *Criteria) Query() orm.QuerySeter
func (*Criteria) RunWithTenant ¶
func (*Criteria) SetDefaults ¶
func (*Criteria) SetDistinct ¶
func (*Criteria) SetRelatedSel ¶
func (*Criteria) SetRelatedsSel ¶
func (*Criteria) SetResults ¶
func (*Criteria) TryOneById ¶
func (*Criteria) WithTenant ¶
type CriteriaExpression ¶
type CriteriaExpression int
const ( Eq CriteriaExpression = 1 + iota Ne Le Lt Ge Gt Like NotLike Between IsNull IsNotNull In NotIn Or AndOr OrAnd AndOrAnd )
type CriteriaLikeMatch ¶
type CriteriaLikeMatch int
const ( Exact CriteriaLikeMatch = 1 + iota IExact StartsWith IStartsWith EndsWith IEndsWith Anywhare IAnywhare )
type CriteriaOrder ¶
type CriteriaResult ¶
type CriteriaResult int
const ( CriteriaList CriteriaResult = 1 + iota CriteriaListAndCount CriteriaOne CriteriaCount CriteriaUpdate CriteriaDelete CriteriaExists CriteriaAggregateOne CriteriaAggregateList )
type CriteriaSet ¶
type CriteriaSet struct {
Criterias []*Criteria
}
func NewCriteriaSet ¶
func NewCriteriaSet() *CriteriaSet
func NewCriteriaSetWithConditions ¶
func NewCriteriaSetWithConditions(criterias ...*Criteria) *CriteriaSet
func (*CriteriaSet) AddCriteria ¶
func (this *CriteriaSet) AddCriteria(criterias ...*Criteria) *CriteriaSet
type DataBase ¶
type DataBase struct {
// contains filtered or unexported fields
}
func NewDataBase ¶
func (*DataBase) BeginWithOpts ¶
func (*DataBase) GetTxOrmer ¶
func (*DataBase) InsertMulti ¶
func (*DataBase) LoadRelated ¶
func (*DataBase) QueryM2M ¶
func (this *DataBase) QueryM2M(entity interface{}, name string) orm.QueryM2Mer
func (*DataBase) QueryTable ¶
func (this *DataBase) QueryTable(ptrStructOrTableName interface{}) orm.QuerySeter
func (*DataBase) ReadOrCreate ¶
type ModelHookAfterList ¶
type ModelHookAfterList interface {
AfterList(entities interface{})
}
type ModelHookAfterLoad ¶
after load
type ModelHookAfterRemove ¶
type ModelHookAfterRemove interface {
AfterRemove() error
}
type ModelHookAfterSave ¶
type ModelHookAfterSave interface {
AfterSave() error
}
after hooks persis
type ModelHookAfterUpdate ¶
type ModelHookAfterUpdate interface {
AfterUpdate() error
}
type ModelHookBeforeCriteria ¶
type ModelHookBeforeCriteria interface {
BeforeCriteria(criteria *Criteria)
}
before load
type ModelHookBeforeQuery ¶
type ModelHookBeforeQuery interface {
BeforeQuery(querySeter orm.QuerySeter) orm.QuerySeter
}
type ModelHookBeforeRemove ¶
type ModelHookBeforeRemove interface {
BeforeRemove() error
}
type ModelHookBeforeSave ¶
type ModelHookBeforeSave interface {
BeforeSave() error
}
before hooks persist
type ModelHookBeforeUpdate ¶
type ModelHookBeforeUpdate interface {
BeforeUpdate() error
}
type Page ¶
type Page struct { Offset int64 Limit int64 Search string Order string Sort string FilterColumns map[string]interface{} AndFilterColumns map[string]interface{} TenantColumnFilter map[string]interface{} }
func (*Page) AddAndInOrConditionFilter ¶
func (*Page) AddFilterAnd ¶
deprecated
func (*Page) AddFilterDefault ¶
deprecated
func (*Page) AddFilterDefaults ¶
deprecated
type RawQuery ¶
type RawQuery struct { Query string Args []interface{} Session *Session Error error RowsAffected int64 // contains filtered or unexported fields }
func NewRawQuery ¶
func NewRawQueryArgs ¶
func NewRawQuerySession ¶
func (*RawQuery) GetValuesFlat ¶
func (this *RawQuery) GetValuesFlat() []interface{}
func (*RawQuery) GetValuesList ¶
func (this *RawQuery) GetValuesList() [][]interface{}
func (*RawQuery) ValuesFlat ¶
func (*RawQuery) ValuesList ¶
func (*RawQuery) WithSession ¶
type RawQueryTransformer ¶
type RawQueryTransformer[T any] struct { RawQuery ValuesTransFn func(map[string]interface{}) (T, error) ListTransFn func([]interface{}) (T, error) }
func NewRawQueryTransformer ¶
func NewRawQueryTransformer[T any](session *Session, query string) *RawQueryTransformer[T]
func NewRawQueryTransformerArgs ¶
func NewRawQueryTransformerArgs[T any](session *Session, query string, args ...interface{}) *RawQueryTransformer[T]
func NewRawQueryTransformerSession ¶
func NewRawQueryTransformerSession[T any](session *Session) *RawQueryTransformer[T]
func (*RawQueryTransformer[T]) First ¶
func (this *RawQueryTransformer[T]) First() (T, error)
func (*RawQueryTransformer[T]) List ¶
func (this *RawQueryTransformer[T]) List() ([]T, error)
func (*RawQueryTransformer[T]) WithListTransformer ¶
func (this *RawQueryTransformer[T]) WithListTransformer(tr func([]interface{}) (T, error)) *RawQueryTransformer[T]
func (*RawQueryTransformer[T]) WithValuesTransformer ¶
func (this *RawQueryTransformer[T]) WithValuesTransformer(tr func(map[string]interface{}) (T, error)) *RawQueryTransformer[T]
type Session ¶
type Session struct { State SessionState Tenant interface{} AuthorizedTenants []TenantModel IgnoreTenantFilter bool IgnoreAuthorizedTenantCheck bool Debug bool DbName string // contains filtered or unexported fields }
func NewSession ¶
func NewSession() *Session
func NewSessionWithDbName ¶
func NewSessionWithTenant ¶
func NewSessionWithTenant(tenant interface{}) *Session
func (*Session) EagerForce ¶
func (*Session) ExecuteDelete ¶
func (this *Session) ExecuteDelete(querySeter orm.QuerySeter) (int64, error)
func (*Session) ExecuteUpdate ¶
func (*Session) HasFilterTenant ¶
func (*Session) IsOpenDbError ¶
func (*Session) OpenTxWithOptsOpt ¶
func (*Session) OpenWithTx ¶
func (*Session) OpenWithoutTx ¶
func (*Session) PageQuery ¶
func (this *Session) PageQuery(query orm.QuerySeter, entity interface{}, entities interface{}, page *Page) error
func (*Session) RemoveCascade ¶
func (*Session) RemoveCascadeDeep ¶
func (*Session) RunWithTenant ¶
func (this *Session) RunWithTenant(tenant interface{}, runner func())
func (*Session) SaveCascade ¶
func (*Session) SaveOrUpdate ¶
func (*Session) SaveOrUpdateCascade ¶
func (*Session) SetAuthorizedTenants ¶
func (*Session) SetCheckAuthorizedTenant ¶
func (*Session) SetDatabase ¶
func (*Session) SetDefaults ¶
func (*Session) SetIgnoreTenantFilter ¶
func (*Session) SetNoAuthSession ¶
func (*Session) SetUseTenantFilter ¶
func (*Session) ToList ¶
func (this *Session) ToList(querySeter orm.QuerySeter, entities interface{}) error
func (*Session) ToOne ¶
func (this *Session) ToOne(querySeter orm.QuerySeter, entity interface{}) error
func (*Session) ToPage ¶
func (this *Session) ToPage(querySeter orm.QuerySeter, entities interface{}, page *Page) error
func (*Session) TryLoadBatch ¶
func (*Session) WithTenant ¶
type SessionState ¶
type SessionState int
const ( SessionStateOk SessionState = iota + 1 SessionStateError )
type TenantModel ¶
type TenantModel interface {
GetId() int64
}
Click to show internal directories.
Click to hide internal directories.