Documentation ¶
Index ¶
- Constants
- Variables
- func AutoIncrTagHandler(ctx *tagContext) error
- func CommentTagHandler(ctx *tagContext) error
- func CreatedTagHandler(ctx *tagContext) error
- func DefaultTagHandler(ctx *tagContext) error
- func DeletedTagHandler(ctx *tagContext) error
- func ExtendsTagHandler(ctx *tagContext) error
- func IgnoreTagHandler(ctx *tagContext) error
- func IndexTagHandler(ctx *tagContext) error
- func LocalTagHandler(ctx *tagContext) error
- func NULLTagHandler(ctx *tagContext) error
- func NotNullTagHandler(ctx *tagContext) error
- func OnlyFromDBTagHandler(ctx *tagContext) error
- func OnlyToDBTagHandler(ctx *tagContext) error
- func PKTagHandler(ctx *tagContext) error
- func SQLTypeTagHandler(ctx *tagContext) error
- func UTCTagHandler(ctx *tagContext) error
- func UniqueTagHandler(ctx *tagContext) error
- func UpdatedTagHandler(ctx *tagContext) error
- func VersionTagHandler(ctx *tagContext) error
- type AfterDeleteProcessor
- type AfterInsertProcessor
- type AfterLoadProcessor
- type AfterLoadSessionProcessor
- type AfterSetProcessor
- type AfterUpdateProcessor
- type BeforeDeleteProcessor
- type BeforeInsertProcessor
- type BeforeSetProcessor
- type BeforeUpdateProcessor
- type Cell
- type DiscardLogger
- func (DiscardLogger) Debug(v ...any)
- func (DiscardLogger) Debugf(format string, v ...any)
- func (DiscardLogger) Error(v ...any)
- func (DiscardLogger) Errorf(format string, v ...any)
- func (DiscardLogger) Info(v ...any)
- func (DiscardLogger) Infof(format string, v ...any)
- func (DiscardLogger) IsShowSQL() bool
- func (DiscardLogger) Level() core.LogLevel
- func (DiscardLogger) SetLevel(l core.LogLevel)
- func (DiscardLogger) ShowSQL(show ...bool)
- func (DiscardLogger) Warn(v ...any)
- func (DiscardLogger) Warnf(format string, v ...any)
- type Engine
- func (engine *Engine) After(closures func(any)) *Session
- func (engine *Engine) Before(closures func(any)) *Session
- func (engine *Engine) Charset(charset string) *Session
- func (engine *Engine) Close() error
- func (engine *Engine) CondDeleted(col *core.Column) builder.Cond
- func (engine *Engine) DB() *core.DB
- func (engine *Engine) DBMetas() ([]*core.Table, error)
- func (engine *Engine) DataSourceName() string
- func (engine *Engine) Dialect() core.Dialect
- func (engine *Engine) DriverName() string
- func (engine *Engine) Exec(sqlOrArgs ...any) (sql.Result, error)
- func (engine *Engine) Find(beans any, condiBeans ...any) error
- func (engine *Engine) GobRegister(v any) *Engine
- func (engine *Engine) ID(id any) *Session
- func (engine *Engine) Insert(beans ...any) (int64, error)
- func (engine *Engine) IsTableExist(beanOrTableName any) (bool, error)
- func (engine *Engine) NewDB() (*core.DB, error)
- func (engine *Engine) NewSession() *Session
- func (engine *Engine) NoAutoTime() *Session
- func (engine *Engine) Ping() error
- func (engine *Engine) Quote(value string) string
- func (engine *Engine) QuoteTo(buf *strings.Builder, value string)
- func (engine *Engine) SQL(query any, args ...any) *Session
- func (engine *Engine) SetColumnMapper(mapper core.IMapper)
- func (engine *Engine) SetConnMaxLifetime(d time.Duration)
- func (engine *Engine) SetLogger(logger core.ILogger)
- func (engine *Engine) SetMapper(mapper core.IMapper)
- func (engine *Engine) SetMaxIdleConns(conns int)
- func (engine *Engine) SetMaxOpenConns(conns int)
- func (engine *Engine) SetTableMapper(mapper core.IMapper)
- func (engine *Engine) ShowExecTime(show ...bool)
- func (engine *Engine) ShowSQL(show ...bool)
- func (engine *Engine) StoreEngine(storeEngine string) *Session
- func (engine *Engine) SupportInsertMany() bool
- func (engine *Engine) Sync(beans ...any) error
- func (engine *Engine) Sync2(beans ...any) error
- func (engine *Engine) Table(tableNameOrBean any) *Session
- func (engine *Engine) TableName(bean any, includeSchema ...bool) string
- func (engine *Engine) Where(query any, args ...any) *Session
- type ErrFieldIsNotExist
- type ErrFieldIsNotValid
- type ErrUnsupportedExprType
- type IterFunc
- type JSONInterface
- type Rows
- type Session
- func (session *Session) After(closures func(any)) *Session
- func (session *Session) Alias(alias string) *Session
- func (session *Session) AllCols() *Session
- func (session *Session) And(query any, args ...any) *Session
- func (session *Session) Asc(colNames ...string) *Session
- func (session *Session) Before(closures func(any)) *Session
- func (session *Session) Begin() error
- func (session *Session) BufferSize(size int) *Session
- func (session *Session) Charset(charset string) *Session
- func (session *Session) Close()
- 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) Count(bean ...interface{}) (int64, error)
- func (session *Session) CreateIndexes(bean any) error
- func (session *Session) CreateTable(bean any) error
- func (session *Session) CreateUniques(bean any) error
- func (session *Session) DB() *core.DB
- func (session *Session) Delete(bean any) (int64, error)
- func (session *Session) Desc(colNames ...string) *Session
- func (session *Session) Distinct(columns ...string) *Session
- func (session *Session) DropIndexes(bean any) error
- func (session *Session) DropTable(beanOrTableName any) error
- func (session *Session) Exec(sqlOrArgs ...any) (sql.Result, error)
- func (session *Session) Exist(bean ...any) (bool, error)
- func (session *Session) Find(rowsSlicePtr any, condiBean ...any) error
- func (session *Session) FindAndCount(rowsSlicePtr any, condiBean ...any) (int64, error)
- func (session *Session) ForUpdate() *Session
- func (session *Session) Get(bean any) (bool, error)
- func (session *Session) GroupBy(keys string) *Session
- func (session *Session) Having(conditions string) *Session
- func (session *Session) ID(id any) *Session
- func (session *Session) Id(id any) *Sessiondeprecated
- func (session *Session) In(column string, args ...any) *Session
- func (session *Session) Init()
- func (session *Session) Insert(beans ...any) (int64, error)
- func (session *Session) InsertMulti(rowsSlicePtr any) (int64, error)
- func (session *Session) InsertOne(bean any) (int64, error)
- func (session *Session) IsClosed() bool
- func (session *Session) IsTableEmpty(bean any) (bool, error)
- func (session *Session) IsTableExist(beanOrTableName any) (bool, error)
- func (session *Session) Iterate(bean interface{}, fun IterFunc) error
- func (session *Session) Join(joinOperator string, tablename any, condition string, args ...any) *Session
- func (session *Session) LastSQL() (string, []any)
- func (session *Session) Limit(limit int, start ...int) *Session
- func (session *Session) MustCols(columns ...string) *Session
- func (session *Session) MustLogSQL(log ...bool) *Session
- func (session *Session) NoAutoCondition(no ...bool) *Session
- func (session *Session) NoAutoTime() *Session
- func (session *Session) NoCache() *Session
- func (session *Session) NotIn(column string, args ...any) *Session
- func (session *Session) Nullable(columns ...string) *Session
- func (session *Session) Omit(columns ...string) *Session
- func (session *Session) Or(query any, args ...any) *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 any, args ...any) *Session
- func (session *Session) Select(str string) *Session
- func (session *Session) Sql(query string, args ...any) *Sessiondeprecated
- 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) Sync2(beans ...any) error
- func (session *Session) Table(tableNameOrBean any) *Session
- func (session *Session) Unscoped() *Session
- func (session *Session) Update(bean any, condiBean ...any) (int64, error)
- func (session *Session) UseBool(columns ...string) *Session
- func (session *Session) Where(query any, args ...any) *Session
- type SimpleLogger
- func (s *SimpleLogger) Debug(v ...any)
- func (s *SimpleLogger) Debugf(format string, v ...any)
- func (s *SimpleLogger) Error(v ...any)
- func (s *SimpleLogger) Errorf(format string, v ...any)
- func (s *SimpleLogger) Info(v ...any)
- func (s *SimpleLogger) Infof(format string, v ...any)
- func (s *SimpleLogger) IsShowSQL() bool
- func (s *SimpleLogger) Level() core.LogLevel
- func (s *SimpleLogger) SetLevel(l core.LogLevel)
- func (s *SimpleLogger) ShowSQL(show ...bool)
- func (s *SimpleLogger) Warn(v ...any)
- func (s *SimpleLogger) Warnf(format string, v ...any)
- type Statement
- func (statement *Statement) Alias(alias string) *Statement
- func (statement *Statement) AllCols() *Statement
- func (statement *Statement) And(query any, args ...any) *Statement
- func (statement *Statement) Asc(colNames ...string) *Statement
- func (statement *Statement) Cols(columns ...string) *Statement
- func (statement *Statement) Decr(column string, arg ...any) *Statement
- func (statement *Statement) Desc(colNames ...string) *Statement
- func (statement *Statement) Distinct(columns ...string) *Statement
- func (statement *Statement) ForUpdate() *Statement
- func (statement *Statement) GroupBy(keys string) *Statement
- func (statement *Statement) Having(conditions string) *Statement
- func (statement *Statement) ID(id any) *Statement
- func (statement *Statement) In(column string, args ...any) *Statement
- func (statement *Statement) Incr(column string, arg ...any) *Statement
- func (statement *Statement) Init()
- func (statement *Statement) Join(joinOP string, tablename any, condition string, args ...any) *Statement
- func (statement *Statement) Limit(limit int, start ...int) *Statement
- func (statement *Statement) MustCols(columns ...string) *Statement
- func (statement *Statement) NoAutoCondition(no ...bool) *Statement
- func (statement *Statement) NotIn(column string, args ...any) *Statement
- func (statement *Statement) Nullable(columns ...string)
- func (statement *Statement) Omit(columns ...string)
- func (statement *Statement) Or(query any, args ...any) *Statement
- func (statement *Statement) OrderBy(order string) *Statement
- func (statement *Statement) SQL(query any, args ...any) *Statement
- func (statement *Statement) Select(str string) *Statement
- func (statement *Statement) SetExpr(column string, expression any) *Statement
- func (statement *Statement) Table(tableNameOrBean any) *Statement
- func (statement *Statement) TableName() string
- func (statement *Statement) Top(limit int) *Statement
- func (statement *Statement) Unscoped() *Statement
- func (statement *Statement) UseBool(columns ...string) *Statement
- func (statement *Statement) Where(query any, args ...any) *Statement
- type StdJSON
- type SyslogLogger
- func (s *SyslogLogger) Debug(v ...any)
- func (s *SyslogLogger) Debugf(format string, v ...any)
- func (s *SyslogLogger) Error(v ...any)
- func (s *SyslogLogger) Errorf(format string, v ...any)
- func (s *SyslogLogger) Info(v ...any)
- func (s *SyslogLogger) Infof(format string, v ...any)
- func (s *SyslogLogger) IsShowSQL() bool
- func (s *SyslogLogger) Level() core.LogLevel
- func (s *SyslogLogger) SetLevel(l core.LogLevel)
- func (s *SyslogLogger) ShowSQL(show ...bool)
- func (s *SyslogLogger) Warn(v ...any)
- func (s *SyslogLogger) Warnf(format string, v ...any)
- type Table
- type TableName
Constants ¶
const ( DEFAULT_LOG_PREFIX = "[xorm]" DEFAULT_LOG_FLAG = log.Ldate | log.Lmicroseconds DEFAULT_LOG_LEVEL = core.LOG_DEBUG )
default log options
const ( // Version show the xorm's version Version string = "0.8.0.1015" )
Variables ¶
var ( // ErrParamsType params error ErrParamsType = errors.New("params type error") // ErrTableNotFound table not found error ErrTableNotFound = errors.New("table not found") // ErrUnSupportedType unsupported error ErrUnSupportedType = errors.New("unsupported type error") // ErrNotExist record does not exist error ErrNotExist = errors.New("record does not exist") // ErrCacheFailed cache failed error ErrCacheFailed = errors.New("cache failed") // ErrNeedDeletedCond delete needs less one condition error ErrNeedDeletedCond = errors.New("delete action needs at least one condition") // ErrNotImplemented not implemented ErrNotImplemented = errors.New("not implemented") // ErrConditionType condition type unsupported ErrConditionType = errors.New("unsupported condition type") // ErrUnSupportedSQLType parameter of SQL is not supported ErrUnSupportedSQLType = errors.New("unsupported sql type") )
var (
// DefaultPostgresSchema default postgres schema
DefaultPostgresSchema = "public"
)
from http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
var ErrNoElementsOnSlice = errors.New("no element on slice when insert")
ErrNoElementsOnSlice represents an error there is no element when insert
Functions ¶
func AutoIncrTagHandler ¶
func AutoIncrTagHandler(ctx *tagContext) error
AutoIncrTagHandler describes autoincr tag handler
func CommentTagHandler ¶
func CommentTagHandler(ctx *tagContext) error
CommentTagHandler add comment to column
func CreatedTagHandler ¶
func CreatedTagHandler(ctx *tagContext) error
CreatedTagHandler describes created tag handler
func DefaultTagHandler ¶
func DefaultTagHandler(ctx *tagContext) error
DefaultTagHandler describes default tag handler
func DeletedTagHandler ¶
func DeletedTagHandler(ctx *tagContext) error
DeletedTagHandler describes deleted tag handler
func ExtendsTagHandler ¶
func ExtendsTagHandler(ctx *tagContext) error
ExtendsTagHandler describes extends tag handler
func IgnoreTagHandler ¶
func IgnoreTagHandler(ctx *tagContext) error
IgnoreTagHandler describes ignored tag handler
func IndexTagHandler ¶
func IndexTagHandler(ctx *tagContext) error
IndexTagHandler describes index tag handler
func LocalTagHandler ¶
func LocalTagHandler(ctx *tagContext) error
LocalTagHandler describes local tag handler
func NULLTagHandler ¶
func NULLTagHandler(ctx *tagContext) error
NULLTagHandler describes null tag handler
func NotNullTagHandler ¶
func NotNullTagHandler(ctx *tagContext) error
NotNullTagHandler describes notnull tag handler
func OnlyFromDBTagHandler ¶
func OnlyFromDBTagHandler(ctx *tagContext) error
OnlyFromDBTagHandler describes mapping direction tag handler
func OnlyToDBTagHandler ¶
func OnlyToDBTagHandler(ctx *tagContext) error
OnlyToDBTagHandler describes mapping direction tag handler
func PKTagHandler ¶
func PKTagHandler(ctx *tagContext) error
PKTagHandler describes primary key tag handler
func SQLTypeTagHandler ¶
func SQLTypeTagHandler(ctx *tagContext) error
SQLTypeTagHandler describes SQL Type tag handler
func UTCTagHandler ¶
func UTCTagHandler(ctx *tagContext) error
UTCTagHandler describes utc tag handler
func UniqueTagHandler ¶
func UniqueTagHandler(ctx *tagContext) error
UniqueTagHandler describes unique tag handler
func UpdatedTagHandler ¶
func UpdatedTagHandler(ctx *tagContext) error
UpdatedTagHandler describes updated tag handler
func VersionTagHandler ¶
func VersionTagHandler(ctx *tagContext) error
VersionTagHandler describes version tag handler
Types ¶
type AfterDeleteProcessor ¶
type AfterDeleteProcessor interface {
AfterDelete()
}
AfterDeleteProcessor executed after an object has been deleted
type AfterInsertProcessor ¶
type AfterInsertProcessor interface {
AfterInsert()
}
AfterInsertProcessor executed after an object is persisted to the database
type AfterLoadProcessor ¶
type AfterLoadProcessor interface {
AfterLoad()
}
AfterLoadProcessor executed after an ojbect has been loaded from database
type AfterLoadSessionProcessor ¶
type AfterLoadSessionProcessor interface {
AfterLoad(*Session)
}
AfterLoadSessionProcessor executed after an ojbect has been loaded from database with session parameter
type AfterSetProcessor ¶
AfterSetProcessor executed after data set to the struct fields
type AfterUpdateProcessor ¶
type AfterUpdateProcessor interface {
AfterUpdate()
}
AfterUpdateProcessor executed after an object has been updated
type BeforeDeleteProcessor ¶
type BeforeDeleteProcessor interface {
BeforeDelete()
}
BeforeDeleteProcessor executed before an object is deleted
type BeforeInsertProcessor ¶
type BeforeInsertProcessor interface {
BeforeInsert()
}
BeforeInsertProcessor executed before an object is initially persisted to the database
type BeforeSetProcessor ¶
BeforeSetProcessor executed before data set to the struct fields
type BeforeUpdateProcessor ¶
type BeforeUpdateProcessor interface {
BeforeUpdate()
}
BeforeUpdateProcessor executed before an object is updated
type DiscardLogger ¶
type DiscardLogger struct{}
DiscardLogger don't log implementation for core.ILogger
func (DiscardLogger) Debugf ¶
func (DiscardLogger) Debugf(format string, v ...any)
Debugf empty implementation
func (DiscardLogger) Errorf ¶
func (DiscardLogger) Errorf(format string, v ...any)
Errorf empty implementation
func (DiscardLogger) Infof ¶
func (DiscardLogger) Infof(format string, v ...any)
Infof empty implementation
func (DiscardLogger) IsShowSQL ¶
func (DiscardLogger) IsShowSQL() bool
IsShowSQL empty implementation
func (DiscardLogger) SetLevel ¶
func (DiscardLogger) SetLevel(l core.LogLevel)
SetLevel empty implementation
func (DiscardLogger) ShowSQL ¶
func (DiscardLogger) ShowSQL(show ...bool)
ShowSQL empty implementation
func (DiscardLogger) Warnf ¶
func (DiscardLogger) Warnf(format string, v ...any)
Warnf empty implementation
type Engine ¶
type Engine struct { ColumnMapper core.IMapper TableMapper core.IMapper TagIdentifier string Tables map[reflect.Type]*core.Table Cacher core.Cacher TZLocation *time.Location // The timezone of the application DatabaseTZ *time.Location // The timezone of the database // contains filtered or unexported fields }
Engine is the major struct of xorm, it means a database manager. Commonly, an application only need one engine
func NewEngine ¶
NewEngine new a db manager according to the parameter. Currently support four drivers
func (*Engine) CondDeleted ¶
CondDeleted returns the conditions whether a record is soft deleted.
func (*Engine) DataSourceName ¶
DataSourceName return the current connection string
func (*Engine) DriverName ¶
DriverName return the current sql driver's name
func (*Engine) Find ¶
Find retrieve records from table, condiBeans's non-empty fields are conditions. beans could be []Struct, []*Struct, map[int64]Struct map[int64]*Struct
func (*Engine) GobRegister ¶
GobRegister register one struct to gob for cache use
func (*Engine) IsTableExist ¶
IsTableExist if a table is exist
func (*Engine) NoAutoTime ¶
NoAutoTime Default if your struct has "created" or "updated" filed tag, the fields will automatically be filled with current time when Insert or Update invoked. Call NoAutoTime if you dont' want to fill automatically.
func (*Engine) SQL ¶
SQL method let's you manually write raw SQL and operate For example:
engine.SQL("select * from user").Find(&users)
This code will execute "select * from user" and set the records to users
func (*Engine) SetColumnMapper ¶
SetColumnMapper set the column name mapping rule
func (*Engine) SetConnMaxLifetime ¶
SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
func (*Engine) SetMaxIdleConns ¶
SetMaxIdleConns set the max idle connections on pool, default is 2
func (*Engine) SetMaxOpenConns ¶
SetMaxOpenConns is only available for go 1.2+
func (*Engine) SetTableMapper ¶
SetTableMapper set the table name mapping rule
func (*Engine) ShowExecTime ¶
ShowExecTime show SQL statement and execute time or not on logger if log level is great than INFO
func (*Engine) ShowSQL ¶
ShowSQL show SQL statement or not on logger if log level is great than INFO
func (*Engine) StoreEngine ¶
StoreEngine set store engine when create table, only support mysql now
func (*Engine) SupportInsertMany ¶
SupportInsertMany If engine's database support batch insert records like "insert into user values (name, age), (name, age)". When the return is ture, then engine.Insert(&users) will generate batch sql and exeute.
func (*Engine) Sync ¶
Sync the new struct changes to database, this method will automatically add table, column, index, unique. but will not delete or change anything. If you change some field, you should change the database manually.
type ErrFieldIsNotExist ¶
ErrFieldIsNotExist columns does not exist
func (ErrFieldIsNotExist) Error ¶
func (e ErrFieldIsNotExist) Error() string
type ErrFieldIsNotValid ¶
ErrFieldIsNotValid is not valid
func (ErrFieldIsNotValid) Error ¶
func (e ErrFieldIsNotValid) Error() string
type ErrUnsupportedExprType ¶
type ErrUnsupportedExprType struct {
// contains filtered or unexported fields
}
func (ErrUnsupportedExprType) Error ¶
func (err ErrUnsupportedExprType) Error() string
type JSONInterface ¶
JSONInterface represents an interface to handle json data
var ( // DefaultJSONHandler default json handler DefaultJSONHandler JSONInterface = StdJSON{} )
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows rows wrapper a rows to
func (*Rows) Err ¶
Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session keep a pointer to sql.DB and provides all execution of all kind of database operations.
func (*Session) BufferSize ¶
BufferSize sets the buffersize for iterate
func (*Session) CreateIndexes ¶
CreateIndexes create indexes
func (*Session) CreateTable ¶
CreateTable create a table according a bean
func (*Session) CreateUniques ¶
CreateUniques create uniques
func (*Session) Desc ¶
Desc provide desc order by query condition, the input parameters are columns.
func (*Session) Distinct ¶
Distinct use for distinct columns. Caution: when you are using cache, distinct will not be cached because cache system need id, but distinct will not provide id
func (*Session) DropIndexes ¶
DropIndexes drop indexes
func (*Session) DropTable ¶
DropTable drop table will drop table if exist, if drop failed, it will return error
func (*Session) Find ¶
Find retrieve records from table, condiBeans's non-empty fields are conditions. beans could be []Struct, []*Struct, map[int64]Struct map[int64]*Struct
func (*Session) FindAndCount ¶
FindAndCount find the results and also return the counts
func (*Session) Get ¶
Get retrieve one record from database, bean's non-empty fields will be as conditions
func (*Session) InsertMulti ¶
InsertMulti insert multiple records
func (*Session) InsertOne ¶
InsertOne insert only one struct into database as a record. The in parameter bean must a struct or a point to struct. The return parameter is inserted and error
func (*Session) IsTableEmpty ¶
IsTableEmpty if table have any records
func (*Session) IsTableExist ¶
IsTableExist if a table is exist
func (*Session) Iterate ¶
Iterate record by record handle records from table, condiBeans's non-empty fields are conditions. beans could be []Struct, []*Struct, map[int64]Struct map[int64]*Struct
func (*Session) Join ¶
func (session *Session) Join(joinOperator string, tablename any, condition string, args ...any) *Session
Join join_operator should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
func (*Session) MustLogSQL ¶
MustLogSQL means record SQL or not and don't follow engine's setting
func (*Session) NoAutoCondition ¶
NoAutoCondition disable generate SQL condition from beans
func (*Session) NoAutoTime ¶
NoAutoTime means do not automatically give created field and updated field the current time on the current session temporarily
func (*Session) NoCache ¶
NoCache ask this session do not retrieve data from cache system and get data from database directly.
func (*Session) OrderBy ¶
OrderBy provide order by query condition, the input parameter is the content after order by on a sql statement.
func (*Session) PingContext ¶
PingContext test if database is ok
func (*Session) Prepare ¶
Prepare set a flag to session that should be prepare statement before execute query
func (*Session) QueryInterface ¶
QueryInterface runs a raw sql and return records as []map[string]interface{}
func (*Session) QuerySliceString ¶
QuerySliceString runs a raw sql and return records as [][]string
func (*Session) QueryString ¶
QueryString runs a raw sql and return records as []map[string]string
func (*Session) Rows ¶
Rows return sql.Rows compatible Rows obj, as a forward Iterator object for iterating record by record, bean's non-empty fields are conditions.
func (*Session) SQL ¶
SQL provides raw sql input parameter. When you have a complex SQL statement and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
func (*Session) StoreEngine ¶
StoreEngine is only avialble mysql dialect currently
func (*Session) Table ¶
Table can input a string or pointer to struct for special a table to operate.
func (*Session) Update ¶
Update records, bean's non-empty fields are updated contents, condiBean' non-empty filds are conditions CAUTION:
1.bool will defaultly be updated content nor conditions You should call UseBool if you have bool to use. 2.float32 & float64 may be not inexact as conditions
type SimpleLogger ¶
type SimpleLogger struct { DEBUG *log.Logger ERR *log.Logger INFO *log.Logger WARN *log.Logger // contains filtered or unexported fields }
SimpleLogger is the default implment of core.ILogger
func NewSimpleLogger ¶
func NewSimpleLogger(out io.Writer) *SimpleLogger
NewSimpleLogger use a special io.Writer as logger output
func (*SimpleLogger) Debugf ¶
func (s *SimpleLogger) Debugf(format string, v ...any)
Debugf implement core.ILogger
func (*SimpleLogger) Errorf ¶
func (s *SimpleLogger) Errorf(format string, v ...any)
Errorf implement core.ILogger
func (*SimpleLogger) Infof ¶
func (s *SimpleLogger) Infof(format string, v ...any)
Infof implement core.ILogger
func (*SimpleLogger) IsShowSQL ¶
func (s *SimpleLogger) IsShowSQL() bool
IsShowSQL implement core.ILogger
func (*SimpleLogger) Level ¶
func (s *SimpleLogger) Level() core.LogLevel
Level implement core.ILogger
func (*SimpleLogger) SetLevel ¶
func (s *SimpleLogger) SetLevel(l core.LogLevel)
SetLevel implement core.ILogger
func (*SimpleLogger) ShowSQL ¶
func (s *SimpleLogger) ShowSQL(show ...bool)
ShowSQL implement core.ILogger
func (*SimpleLogger) Warnf ¶
func (s *SimpleLogger) Warnf(format string, v ...any)
Warnf implement core.ILogger
type Statement ¶
type Statement struct { RefTable *core.Table Engine *Engine Start int LimitN *int OrderStr string JoinStr string GroupByStr string HavingStr string ColumnStr string OmitStr string AltTableName string RawSQL string RawParams []any UseAutoJoin bool StoreEngine string Charset string UseCache bool UseAutoTime bool IsDistinct bool IsForUpdate bool TableAlias string // contains filtered or unexported fields }
Statement save all the sql info for executing SQL
func (*Statement) ID ¶
ID generate "where id = ? " statement or for composite key "where key1 = ? and key2 = ?"
func (*Statement) Join ¶
func (statement *Statement) Join(joinOP string, tablename any, condition string, args ...any) *Statement
Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
func (*Statement) NoAutoCondition ¶
NoAutoCondition if you do not want convert bean's field as query condition, then use this function
func (*Statement) Nullable ¶
Nullable Update use only: update columns to null when value is nullable and zero-value
func (*Statement) Table ¶
Table tempororily set table name, the parameter could be a string or a pointer of struct
type StdJSON ¶
type StdJSON struct{}
StdJSON implements JSONInterface via encoding/json
type SyslogLogger ¶
type SyslogLogger struct {
// contains filtered or unexported fields
}
SyslogLogger will be depricated
func NewSyslogLogger ¶
func NewSyslogLogger(w *syslog.Writer) *SyslogLogger
NewSyslogLogger implements core.ILogger
func (*SyslogLogger) Debugf ¶
func (s *SyslogLogger) Debugf(format string, v ...any)
Debugf log content as Debug and format
func (*SyslogLogger) Errorf ¶
func (s *SyslogLogger) Errorf(format string, v ...any)
Errorf log content as Errorf and format
func (*SyslogLogger) Infof ¶
func (s *SyslogLogger) Infof(format string, v ...any)
Infof log content as Infof and format
func (*SyslogLogger) SetLevel ¶
func (s *SyslogLogger) SetLevel(l core.LogLevel)
SetLevel always return error, as current log/syslog package doesn't allow to set priority level after syslog.Writer created
func (*SyslogLogger) ShowSQL ¶
func (s *SyslogLogger) ShowSQL(show ...bool)
ShowSQL set if logging SQL
func (*SyslogLogger) Warnf ¶
func (s *SyslogLogger) Warnf(format string, v ...any)
Warnf log content as Warnf and format
Source Files ¶
- convert.go
- dialect_mysql.go
- dialect_postgres.go
- dialect_sqlite3.go
- engine.go
- engine_cond.go
- engine_table.go
- error.go
- helpers.go
- json.go
- logger.go
- processors.go
- rows.go
- session.go
- session_cols.go
- session_cond.go
- session_context.go
- session_convert.go
- session_delete.go
- session_exist.go
- session_find.go
- session_get.go
- session_insert.go
- session_iterate.go
- session_query.go
- session_raw.go
- session_schema.go
- session_stats.go
- session_tx.go
- session_update.go
- statement.go
- statement_args.go
- statement_columnmap.go
- statement_exprparam.go
- statement_quote.go
- syslogger.go
- table_name.go
- tag.go
- xorm.go