Versions in this module Expand all Collapse all v1 v1.0.1 Jan 9, 2023 v1.0.0 Jul 12, 2022 Changes in this version + var ErrCacheFailed = errors.New("Cache failed") + var ErrConditionType = errors.New("Unsupported condition type") + var ErrInitEngine = errors.New("init xorm engine: config or config.Url can not be null") + var ErrNeedDeletedCond = errors.New("Delete action needs at least one condition") + var ErrNoColumnsTobeUpdated = errors.New("no columns found to be updated") + var ErrNoElementsOnSlice = errors.New("no element on slice when insert") + var ErrNotExist = errors.New("Record does not exist") + var ErrNotImplemented = errors.New("Not implemented") + var ErrObjectIsNil = errors.New("object should not be nil") + var ErrPageableCannotBeNil = errors.New("pageable cannot be nil") + var ErrParamsType = errors.New("Params type error") + var ErrPtrSliceType = errors.New("A point to a slice is needed") + var ErrTableNotFound = errors.New("Table not found") + var ErrUnSupportedType = errors.New("Unsupported type error") + type AfterDeleteProcessor interface + AfterDelete func() + type AfterInsertProcessor interface + AfterInsert func() + type AfterLoadProcessor interface + AfterLoad func() + type AfterLoadSessionProcessor interface + AfterLoad func(*Session) + type AfterSetProcessor interface + AfterSet func(string, Cell) + type AfterUpdateProcessor interface + AfterUpdate func() + type BeforeDeleteProcessor interface + BeforeDelete func() + type BeforeInsertProcessor interface + BeforeInsert func() + type BeforeSetProcessor interface + BeforeSet func(string, Cell) + type BeforeUpdateProcessor interface + BeforeUpdate func() + type Cell *interface + type Config struct + Driver string + Master string + MaxConn int + MaxIdle int + ShowSql bool + Slaves []string + type Engine struct + DatabaseTZ *time.Location + TZLocation *time.Location + func NewEngine(driverName string, dataSourceName string) (*Engine, error) + func NewEngineWithDB(driverName string, dataSourceName string, db *core.DB) (*Engine, error) + func NewEngineWithDialectAndDB(driverName, dataSourceName string, dialect dialects.Dialect, db *core.DB) (*Engine, error) + func NewEngineWithParams(driverName string, dataSourceName string, params map[string]string) (*Engine, error) + func (engine *Engine) AddHook(hook contexts.Hook) + func (engine *Engine) After(closures func(interface{})) *Session + func (engine *Engine) Alias(alias string) *Session + func (engine *Engine) AllCols() *Session + func (engine *Engine) Asc(colNames ...string) *Session + func (engine *Engine) Before(closures func(interface{})) *Session + func (engine *Engine) BufferSize(size int) *Session + func (engine *Engine) Cascade(trueOrFalse ...bool) *Session + func (engine *Engine) Charset(charset string) *Session + func (engine *Engine) ClearCache(beans ...interface{}) error + func (engine *Engine) ClearCacheBean(bean interface{}, id string) error + func (engine *Engine) Close() error + func (engine *Engine) Cols(columns ...string) *Session + func (engine *Engine) Context(ctx context.Context) *Session + func (engine *Engine) Count(bean ...interface{}) (int64, error) + func (engine *Engine) CreateIndexes(bean interface{}) error + func (engine *Engine) CreateTables(beans ...interface{}) error + func (engine *Engine) CreateUniques(bean interface{}) error + func (engine *Engine) DB() *core.DB + func (engine *Engine) DBMetas() ([]*schemas.Table, error) + func (engine *Engine) DBVersion() (*schemas.Version, error) + func (engine *Engine) DataSourceName() string + func (engine *Engine) Decr(column string, arg ...interface{}) *Session + func (engine *Engine) Delete(beans ...interface{}) (int64, error) + func (engine *Engine) Desc(colNames ...string) *Session + func (engine *Engine) Dialect() dialects.Dialect + func (engine *Engine) Distinct(columns ...string) *Session + func (engine *Engine) DriverName() string + func (engine *Engine) DropIndexes(bean interface{}) error + func (engine *Engine) DropTables(beans ...interface{}) error + func (engine *Engine) DumpAll(w io.Writer, tp ...schemas.DBType) error + func (engine *Engine) DumpAllToFile(fp string, tp ...schemas.DBType) error + func (engine *Engine) DumpTables(tables []*schemas.Table, w io.Writer, tp ...schemas.DBType) error + func (engine *Engine) DumpTablesToFile(tables []*schemas.Table, fp string, tp ...schemas.DBType) error + func (engine *Engine) EnableSessionID(enable bool) + func (engine *Engine) Exec(sqlOrArgs ...interface{}) (sql.Result, error) + func (engine *Engine) Exist(bean ...interface{}) (bool, error) + func (engine *Engine) Find(beans interface{}, condiBeans ...interface{}) error + func (engine *Engine) FindAndCount(rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error) + func (engine *Engine) FindPagination(rowsSlicePtr interface{}, p pageable.Pageable, condiBean ...interface{}) (*pageable.Pagination, error) + func (engine *Engine) Get(beans ...interface{}) (bool, error) + func (engine *Engine) GetCacher(tableName string) caches.Cacher + func (engine *Engine) GetColumnMapper() names.Mapper + func (engine *Engine) GetDefaultCacher() caches.Cacher + func (engine *Engine) GetTZDatabase() *time.Location + func (engine *Engine) GetTZLocation() *time.Location + func (engine *Engine) GetTableMapper() names.Mapper + func (engine *Engine) GroupBy(keys string) *Session + func (engine *Engine) Having(conditions string) *Session + func (engine *Engine) ID(id interface{}) *Session + func (engine *Engine) Import(r io.Reader) ([]sql.Result, error) + func (engine *Engine) ImportFile(ddlPath string) ([]sql.Result, error) + func (engine *Engine) In(column string, args ...interface{}) *Session + func (engine *Engine) Incr(column string, arg ...interface{}) *Session + func (engine *Engine) Insert(beans ...interface{}) (int64, error) + func (engine *Engine) InsertOne(bean interface{}) (int64, error) + func (engine *Engine) IsTableEmpty(bean interface{}) (bool, error) + func (engine *Engine) IsTableExist(beanOrTableName interface{}) (bool, error) + func (engine *Engine) Iterate(bean interface{}, fun IterFunc) error + func (engine *Engine) Join(joinOperator string, tablename interface{}, condition string, ...) *Session + func (engine *Engine) Limit(limit int, start ...int) *Session + func (engine *Engine) Logger() log.ContextLogger + func (engine *Engine) MapCacher(bean interface{}, cacher caches.Cacher) error + func (engine *Engine) MustCols(columns ...string) *Session + func (engine *Engine) NewDB() (*core.DB, error) + func (engine *Engine) NewSession() *Session + func (engine *Engine) NoAutoCondition(no ...bool) *Session + func (engine *Engine) NoAutoTime() *Session + func (engine *Engine) NoCache() *Session + func (engine *Engine) NoCascade() *Session + func (engine *Engine) NotIn(column string, args ...interface{}) *Session + func (engine *Engine) Nullable(columns ...string) *Session + func (engine *Engine) Omit(columns ...string) *Session + func (engine *Engine) OrderBy(order string) *Session + func (engine *Engine) Ping() error + func (engine *Engine) PingContext(ctx context.Context) error + func (engine *Engine) Prepare() *Session + func (engine *Engine) Query(sqlOrArgs ...interface{}) (resultsSlice []map[string][]byte, err error) + func (engine *Engine) QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error) + func (engine *Engine) QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error) + func (engine *Engine) Quote(value string) string + func (engine *Engine) QuoteTo(buf *strings.Builder, value string) + func (engine *Engine) Rows(bean interface{}) (*Rows, error) + func (engine *Engine) SQL(query interface{}, args ...interface{}) *Session + func (engine *Engine) SQLType(c *schemas.Column) string + func (engine *Engine) ScanInterfaceMap(rows *core.Rows) (map[string]interface{}, error) + func (engine *Engine) ScanInterfaceMaps(rows *core.Rows) (resultsSlice []map[string]interface{}, err error) + func (engine *Engine) ScanStringMap(rows *core.Rows) (map[string]string, error) + func (engine *Engine) ScanStringMaps(rows *core.Rows) (resultsSlice []map[string]string, err error) + func (engine *Engine) ScanStringSlice(rows *core.Rows) ([]string, error) + func (engine *Engine) ScanStringSlices(rows *core.Rows) (resultsSlice [][]string, err error) + func (engine *Engine) Select(str string) *Session + func (engine *Engine) SetCacher(tableName string, cacher caches.Cacher) + func (engine *Engine) SetColumnMapper(mapper names.Mapper) + func (engine *Engine) SetConnMaxLifetime(d time.Duration) + func (engine *Engine) SetDefaultCacher(cacher caches.Cacher) + func (engine *Engine) SetDefaultContext(ctx context.Context) + func (engine *Engine) SetDisableGlobalCache(disable bool) + func (engine *Engine) SetExpr(column string, expression interface{}) *Session + func (engine *Engine) SetLogLevel(level log.LogLevel) + func (engine *Engine) SetLogger(logger interface{}) + func (engine *Engine) SetMapper(mapper names.Mapper) + func (engine *Engine) SetMaxIdleConns(conns int) + func (engine *Engine) SetMaxOpenConns(conns int) + func (engine *Engine) SetQuotePolicy(quotePolicy dialects.QuotePolicy) + func (engine *Engine) SetSchema(schema string) + func (engine *Engine) SetTZDatabase(tz *time.Location) + func (engine *Engine) SetTZLocation(tz *time.Location) + func (engine *Engine) SetTableMapper(mapper names.Mapper) + func (engine *Engine) SetTagIdentifier(tagIdentifier string) + func (engine *Engine) ShowSQL(show ...bool) + func (engine *Engine) StoreEngine(storeEngine string) *Session + func (engine *Engine) Sum(bean interface{}, colName string) (float64, error) + func (engine *Engine) SumInt(bean interface{}, colName string) (int64, error) + func (engine *Engine) Sums(bean interface{}, colNames ...string) ([]float64, error) + func (engine *Engine) SumsInt(bean interface{}, colNames ...string) ([]int64, error) + func (engine *Engine) Sync(beans ...interface{}) error + func (engine *Engine) Sync2(beans ...interface{}) error + func (engine *Engine) Table(tableNameOrBean interface{}) *Session + func (engine *Engine) TableInfo(bean interface{}) (*schemas.Table, error) + func (engine *Engine) TableName(bean interface{}, includeSchema ...bool) string + func (engine *Engine) Transaction(f func(*Session) (interface{}, error)) (interface{}, error) + func (engine *Engine) UnMapType(t reflect.Type) + func (engine *Engine) Unscoped() *Session + func (engine *Engine) Update(bean interface{}, condiBeans ...interface{}) (int64, error) + func (engine *Engine) UseBool(columns ...string) *Session + func (engine *Engine) Where(query interface{}, args ...interface{}) *Session + type EngineGroup struct + func NewEngineGroup(args1 interface{}, args2 interface{}, policies ...GroupPolicy) (*EngineGroup, error) + func (eg *EngineGroup) AddHook(hook contexts.Hook) + func (eg *EngineGroup) Close() error + func (eg *EngineGroup) Context(ctx context.Context) *Session + func (eg *EngineGroup) Master() *Engine + func (eg *EngineGroup) NewSession() *Session + func (eg *EngineGroup) Ping() error + func (eg *EngineGroup) Query(sqlOrArgs ...interface{}) (resultsSlice []map[string][]byte, err error) + func (eg *EngineGroup) QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error) + func (eg *EngineGroup) QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error) + func (eg *EngineGroup) Rows(bean interface{}) (*Rows, error) + func (eg *EngineGroup) SetColumnMapper(mapper names.Mapper) + func (eg *EngineGroup) SetConnMaxLifetime(d time.Duration) + func (eg *EngineGroup) SetDefaultCacher(cacher caches.Cacher) + func (eg *EngineGroup) SetLogLevel(level log.LogLevel) + func (eg *EngineGroup) SetLogger(logger interface{}) + func (eg *EngineGroup) SetMapper(mapper names.Mapper) + func (eg *EngineGroup) SetMaxIdleConns(conns int) + func (eg *EngineGroup) SetMaxOpenConns(conns int) + func (eg *EngineGroup) SetPolicy(policy GroupPolicy) *EngineGroup + func (eg *EngineGroup) SetQuotePolicy(quotePolicy dialects.QuotePolicy) + func (eg *EngineGroup) SetTableMapper(mapper names.Mapper) + func (eg *EngineGroup) SetTagIdentifier(tagIdentifier string) + func (eg *EngineGroup) ShowSQL(show ...bool) + func (eg *EngineGroup) Slave() *Engine + func (eg *EngineGroup) Slaves() []*Engine + type EngineInterface interface + AddHook func(hook contexts.Hook) + Before func(func(interface{})) *Session + Charset func(charset string) *Session + ClearCache func(...interface{}) error + Context func(context.Context) *Session + CreateTables func(...interface{}) error + DBMetas func() ([]*schemas.Table, error) + DBVersion func() (*schemas.Version, error) + Dialect func() dialects.Dialect + DriverName func() string + DropTables func(...interface{}) error + DumpAllToFile func(fp string, tp ...schemas.DBType) error + EnableSessionID func(bool) + GetCacher func(string) caches.Cacher + GetColumnMapper func() names.Mapper + GetDefaultCacher func() caches.Cacher + GetTZDatabase func() *time.Location + GetTZLocation func() *time.Location + GetTableMapper func() names.Mapper + ImportFile func(fp string) ([]sql.Result, error) + MapCacher func(interface{}, caches.Cacher) error + NewSession func() *Session + NoAutoTime func() *Session + Prepare func() *Session + Quote func(string) string + SetCacher func(string, caches.Cacher) + SetColumnMapper func(names.Mapper) + SetConnMaxLifetime func(time.Duration) + SetDefaultCacher func(caches.Cacher) + SetLogLevel func(log.LogLevel) + SetLogger func(logger interface{}) + SetMapper func(names.Mapper) + SetMaxIdleConns func(int) + SetMaxOpenConns func(int) + SetQuotePolicy func(dialects.QuotePolicy) + SetSchema func(string) + SetTZDatabase func(tz *time.Location) + SetTZLocation func(tz *time.Location) + SetTableMapper func(names.Mapper) + SetTagIdentifier func(string) + ShowSQL func(show ...bool) + StoreEngine func(storeEngine string) *Session + Sync func(...interface{}) error + Sync2 func(...interface{}) error + TableInfo func(bean interface{}) (*schemas.Table, error) + TableName func(interface{}, ...bool) string + UnMapType func(reflect.Type) + func NewEnginePlus(c *Config, w ...io.Writer) (EngineInterface, error) + type ErrFieldIsNotExist struct + FieldName string + TableName string + func (e ErrFieldIsNotExist) Error() string + type ErrFieldIsNotValid struct + FieldName string + TableName string + func (e ErrFieldIsNotValid) Error() string + type GroupPolicy interface + Slave func(*EngineGroup) *Engine + type GroupPolicyHandler func(*EngineGroup) *Engine + func LeastConnPolicy() GroupPolicyHandler + func RandomPolicy() GroupPolicyHandler + func RoundRobinPolicy() GroupPolicyHandler + func WeightRandomPolicy(weights []int) GroupPolicyHandler + func WeightRoundRobinPolicy(weights []int) GroupPolicyHandler + func (h GroupPolicyHandler) Slave(eg *EngineGroup) *Engine + type Interface interface + Alias func(alias string) *Session + AllCols func() *Session + Asc func(colNames ...string) *Session + BufferSize func(size int) *Session + Cols func(columns ...string) *Session + Count func(...interface{}) (int64, error) + CreateIndexes func(bean interface{}) error + CreateUniques func(bean interface{}) error + Decr func(column string, arg ...interface{}) *Session + Delete func(...interface{}) (int64, error) + Desc func(...string) *Session + Distinct func(columns ...string) *Session + DropIndexes func(bean interface{}) error + Exec func(sqlOrArgs ...interface{}) (sql.Result, error) + Exist func(bean ...interface{}) (bool, error) + Find func(interface{}, ...interface{}) error + FindAndCount func(interface{}, ...interface{}) (int64, error) + FindPagination func(rowsSlicePtr interface{}, p pageable.Pageable, condiBean ...interface{}) (*pageable.Pagination, error) + Get func(...interface{}) (bool, error) + GroupBy func(keys string) *Session + ID func(interface{}) *Session + In func(string, ...interface{}) *Session + Incr func(column string, arg ...interface{}) *Session + Insert func(...interface{}) (int64, error) + InsertOne func(interface{}) (int64, error) + IsTableEmpty func(bean interface{}) (bool, error) + IsTableExist func(beanOrTableName interface{}) (bool, error) + Iterate func(interface{}, IterFunc) error + Join func(joinOperator string, tablename interface{}, condition string, ...) *Session + Limit func(int, ...int) *Session + MustCols func(columns ...string) *Session + NoAutoCondition func(...bool) *Session + NotIn func(string, ...interface{}) *Session + Nullable func(...string) *Session + Omit func(columns ...string) *Session + OrderBy func(order string) *Session + Ping func() error + Query func(sqlOrArgs ...interface{}) (resultsSlice []map[string][]byte, err error) + QueryInterface func(sqlOrArgs ...interface{}) ([]map[string]interface{}, error) + QueryString func(sqlOrArgs ...interface{}) ([]map[string]string, error) + Rows func(bean interface{}) (*Rows, error) + SQL func(interface{}, ...interface{}) *Session + Select func(string) *Session + SetExpr func(string, interface{}) *Session + Sum func(bean interface{}, colName string) (float64, error) + SumInt func(bean interface{}, colName string) (int64, error) + Sums func(bean interface{}, colNames ...string) ([]float64, error) + SumsInt func(bean interface{}, colNames ...string) ([]int64, error) + Table func(tableNameOrBean interface{}) *Session + Unscoped func() *Session + Update func(bean interface{}, condiBeans ...interface{}) (int64, error) + UseBool func(...string) *Session + Where func(interface{}, ...interface{}) *Session + type IterFunc func(idx int, bean interface{}) error + type Rows struct + func (rows *Rows) Close() error + func (rows *Rows) Err() error + func (rows *Rows) Next() bool + func (rows *Rows) Scan(beans ...interface{}) error + type Session struct + func (session *Session) After(closures func(interface{})) *Session + func (session *Session) Alias(alias string) *Session + func (session *Session) AllCols() *Session + func (session *Session) And(query interface{}, args ...interface{}) *Session + func (session *Session) Asc(colNames ...string) *Session + func (session *Session) Before(closures func(interface{})) *Session + func (session *Session) Begin() error + func (session *Session) BufferSize(size int) *Session + func (session *Session) Cascade(trueOrFalse ...bool) *Session + func (session *Session) Charset(charset string) *Session + func (session *Session) Close() error + func (session *Session) Cols(columns ...string) *Session + func (session *Session) Commit() error + func (session *Session) Conds() builder.Cond + func (session *Session) Context(ctx context.Context) *Session + func (session *Session) ContextCache(context contexts.ContextCache) *Session + func (session *Session) Count(bean ...interface{}) (int64, error) + func (session *Session) CreateIndexes(bean interface{}) error + func (session *Session) CreateTable(bean interface{}) error + func (session *Session) CreateUniques(bean interface{}) error + func (session *Session) DB() *core.DB + func (session *Session) Decr(column string, arg ...interface{}) *Session + func (session *Session) Delete(beans ...interface{}) (int64, error) + func (session *Session) Desc(colNames ...string) *Session + func (session *Session) Distinct(columns ...string) *Session + func (session *Session) DropIndexes(bean interface{}) error + func (session *Session) DropTable(beanOrTableName interface{}) error + func (session *Session) Engine() *Engine + func (session *Session) Exec(sqlOrArgs ...interface{}) (sql.Result, error) + func (session *Session) Exist(bean ...interface{}) (bool, error) + func (session *Session) Find(rowsSlicePtr interface{}, condiBean ...interface{}) error + func (session *Session) FindAndCount(rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error) + func (session *Session) FindPagination(rowsSlicePtr interface{}, page pageable.Pageable, condiBean ...interface{}) (*pageable.Pagination, error) + func (session *Session) ForUpdate() *Session + func (session *Session) Get(beans ...interface{}) (bool, error) + func (session *Session) GroupBy(keys string) *Session + func (session *Session) Having(conditions string) *Session + func (session *Session) ID(id interface{}) *Session + func (session *Session) Import(r io.Reader) ([]sql.Result, error) + func (session *Session) ImportFile(ddlPath string) ([]sql.Result, error) + func (session *Session) In(column string, args ...interface{}) *Session + func (session *Session) Incr(column string, arg ...interface{}) *Session + func (session *Session) Insert(beans ...interface{}) (int64, error) + func (session *Session) InsertMulti(rowsSlicePtr interface{}) (int64, error) + func (session *Session) InsertOne(bean interface{}) (int64, error) + func (session *Session) IsClosed() bool + func (session *Session) IsInTx() bool + func (session *Session) IsTableEmpty(bean interface{}) (bool, error) + func (session *Session) IsTableExist(beanOrTableName interface{}) (bool, error) + func (session *Session) Iterate(bean interface{}, fun IterFunc) error + func (session *Session) Join(joinOperator string, tablename interface{}, condition string, ...) *Session + func (session *Session) LastSQL() (string, []interface{}) + func (session *Session) Limit(limit int, start ...int) *Session + func (session *Session) MustCols(columns ...string) *Session + func (session *Session) MustLogSQL(logs ...bool) *Session + func (session *Session) NoAutoCondition(no ...bool) *Session + func (session *Session) NoAutoTime() *Session + func (session *Session) NoCache() *Session + func (session *Session) NoCascade() *Session + func (session *Session) NotIn(column string, args ...interface{}) *Session + func (session *Session) Nullable(columns ...string) *Session + func (session *Session) Omit(columns ...string) *Session + func (session *Session) Or(query interface{}, args ...interface{}) *Session + func (session *Session) OrderBy(order string) *Session + func (session *Session) Ping() error + func (session *Session) PingContext(ctx context.Context) error + func (session *Session) Prepare() *Session + func (session *Session) Query(sqlOrArgs ...interface{}) ([]map[string][]byte, error) + func (session *Session) QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error) + func (session *Session) QuerySliceString(sqlOrArgs ...interface{}) ([][]string, error) + func (session *Session) QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error) + func (session *Session) Rollback() error + func (session *Session) Rows(bean interface{}) (*Rows, error) + func (session *Session) SQL(query interface{}, args ...interface{}) *Session + func (session *Session) Select(str string) *Session + func (session *Session) SetExpr(column string, expression interface{}) *Session + func (session *Session) StoreEngine(storeEngine string) *Session + func (session *Session) Sum(bean interface{}, columnName string) (res float64, err error) + func (session *Session) SumInt(bean interface{}, columnName string) (res int64, err error) + func (session *Session) Sums(bean interface{}, columnNames ...string) ([]float64, error) + func (session *Session) SumsInt(bean interface{}, columnNames ...string) ([]int64, error) + func (session *Session) Sync(beans ...interface{}) error + func (session *Session) Sync2(beans ...interface{}) error + func (session *Session) Table(tableNameOrBean interface{}) *Session + func (session *Session) Tx() *core.Tx + func (session *Session) Unscoped() *Session + func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int64, error) + func (session *Session) UseBool(columns ...string) *Session + func (session *Session) Where(query interface{}, args ...interface{}) *Session