Versions in this module Expand all Collapse all v1 v1.12.2 Dec 24, 2020 v1.12.1 Dec 8, 2020 Changes in this version + const ColAdd + const ColExcept + const ColMinus + const ColMultiply + const CommaSpace + const DebugQueries + const ExprSep + const IsFieldType + const IsIntegerField + const IsPositiveIntegerField + const IsRelField + const RelForeignKey + const RelManyToMany + const RelOneToOne + const RelReverseMany + const RelReverseOne + const TypeBigIntegerField + const TypeBitField + const TypeBooleanField + const TypeCharField + const TypeDateField + const TypeDateTimeField + const TypeDecimalField + const TypeFloatField + const TypeIntegerField + const TypeJSONField + const TypeJsonbField + const TypePositiveBigIntegerField + const TypePositiveBitField + const TypePositiveIntegerField + const TypePositiveSmallIntegerField + const TypeSmallIntegerField + const TypeTextField + const TypeTimeField + const TypeVarCharField + var Debug = false + var DebugLog = NewLog(os.Stdout) + var DefaultRelsDepth = 2 + var DefaultRowsLimit = -1 + var DefaultTimeLoc = time.Local + var ErrArgs = errors.New("<Ormer> args error may be empty") + var ErrMissPK = errors.New("missed pk value") + var ErrMultiRows = errors.New("<QuerySeter> return multi rows") + var ErrNoRows = errors.New("<QuerySeter> no row found") + var ErrNotImplement = errors.New("have not implement") + var ErrStmtClosed = errors.New("<QuerySeter> stmt already closed") + var ErrTxDone = errors.New("<Ormer.Commit/Rollback> transaction not begin") + var ErrTxHasBegan = errors.New("<Ormer.Begin> transaction already begin") + var LogFunc func(query map[string]interface{}) + var SnakeAcronymNameStrategy = "snakeStringWithAcronym" + func AddAliasWthDB(aliasName, driverName string, db *sql.DB) error + func BootStrap() + func ColValue(opt operator, value interface{}) interface + func GetDB(aliasNames ...string) (*sql.DB, error) + func RegisterDataBase(aliasName, driverName, dataSource string, params ...int) error + func RegisterDriver(driverName string, typ DriverType) error + func RegisterModel(models ...interface{}) + func RegisterModelWithPrefix(prefix string, models ...interface{}) + func RegisterModelWithSuffix(suffix string, models ...interface{}) + func ResetModelCache() + func RunCommand() + func RunSyncdb(name string, force bool, verbose bool) error + func SetDataBaseTZ(aliasName string, tz *time.Location) error + func SetMaxIdleConns(aliasName string, maxIdleConns int) + func SetMaxOpenConns(aliasName string, maxOpenConns int) + func SetNameStrategy(s string) + func ToInt64(value interface{}) (d int64) + func ToStr(value interface{}, args ...int) (s string) + type BigIntegerField int64 + func (e *BigIntegerField) FieldType() int + func (e *BigIntegerField) RawValue() interface{} + func (e *BigIntegerField) Set(d int64) + func (e *BigIntegerField) SetRaw(value interface{}) error + func (e *BigIntegerField) String() string + func (e BigIntegerField) Value() int64 + type BooleanField bool + func (e *BooleanField) FieldType() int + func (e *BooleanField) RawValue() interface{} + func (e *BooleanField) Set(d bool) + func (e *BooleanField) SetRaw(value interface{}) error + func (e *BooleanField) String() string + func (e BooleanField) Value() bool + type CharField string + func (e *CharField) FieldType() int + func (e *CharField) RawValue() interface{} + func (e *CharField) Set(d string) + func (e *CharField) SetRaw(value interface{}) error + func (e *CharField) String() string + func (e CharField) Value() string + type Condition struct + func NewCondition() *Condition + func (c *Condition) AndCond(cond *Condition) *Condition + func (c *Condition) AndNotCond(cond *Condition) *Condition + func (c *Condition) IsEmpty() bool + func (c *Condition) OrCond(cond *Condition) *Condition + func (c *Condition) OrNotCond(cond *Condition) *Condition + func (c Condition) And(expr string, args ...interface{}) *Condition + func (c Condition) AndNot(expr string, args ...interface{}) *Condition + func (c Condition) Or(expr string, args ...interface{}) *Condition + func (c Condition) OrNot(expr string, args ...interface{}) *Condition + func (c Condition) Raw(expr string, sql string) *Condition + type DB struct + DB *sql.DB + func (d *DB) Begin() (*sql.Tx, error) + func (d *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) + func (d *DB) Exec(query string, args ...interface{}) (sql.Result, error) + func (d *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + func (d *DB) Prepare(query string) (*sql.Stmt, error) + func (d *DB) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) + func (d *DB) Query(query string, args ...interface{}) (*sql.Rows, error) + func (d *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + func (d *DB) QueryRow(query string, args ...interface{}) *sql.Row + func (d *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row + type DateField time.Time + func (e *DateField) FieldType() int + func (e *DateField) RawValue() interface{} + func (e *DateField) Set(d time.Time) + func (e *DateField) SetRaw(value interface{}) error + func (e *DateField) String() string + func (e DateField) Value() time.Time + type DateTimeField time.Time + func (e *DateTimeField) FieldType() int + func (e *DateTimeField) RawValue() interface{} + func (e *DateTimeField) Set(d time.Time) + func (e *DateTimeField) SetRaw(value interface{}) error + func (e *DateTimeField) String() string + func (e DateTimeField) Value() time.Time + type Driver interface + Name func() string + Type func() DriverType + type DriverType int + const DRDM + const DRMySQL + const DROracle + const DRPostgres + const DRSqlite + const DRTiDB + type Fielder interface + FieldType func() int + RawValue func() interface{} + SetRaw func(interface{}) error + String func() string + type FloatField float64 + func (e *FloatField) FieldType() int + func (e *FloatField) RawValue() interface{} + func (e *FloatField) Set(d float64) + func (e *FloatField) SetRaw(value interface{}) error + func (e *FloatField) String() string + func (e FloatField) Value() float64 + type Inserter interface + Close func() error + Insert func(interface{}) (int64, error) + type IntegerField int32 + func (e *IntegerField) FieldType() int + func (e *IntegerField) RawValue() interface{} + func (e *IntegerField) Set(d int32) + func (e *IntegerField) SetRaw(value interface{}) error + func (e *IntegerField) String() string + func (e IntegerField) Value() int32 + type JSONField string + func (j *JSONField) FieldType() int + func (j *JSONField) RawValue() interface{} + func (j *JSONField) Set(d string) + func (j *JSONField) SetRaw(value interface{}) error + func (j *JSONField) String() string + func (j JSONField) Value() string + type JsonbField string + func (j *JsonbField) FieldType() int + func (j *JsonbField) RawValue() interface{} + func (j *JsonbField) Set(d string) + func (j *JsonbField) SetRaw(value interface{}) error + func (j *JsonbField) String() string + func (j JsonbField) Value() string + type Log struct + func NewLog(out io.Writer) *Log + type MySQLQueryBuilder struct + Tokens []string + func (qb *MySQLQueryBuilder) And(cond string) QueryBuilder + func (qb *MySQLQueryBuilder) Asc() QueryBuilder + func (qb *MySQLQueryBuilder) Delete(tables ...string) QueryBuilder + func (qb *MySQLQueryBuilder) Desc() QueryBuilder + func (qb *MySQLQueryBuilder) ForUpdate() QueryBuilder + func (qb *MySQLQueryBuilder) From(tables ...string) QueryBuilder + func (qb *MySQLQueryBuilder) GroupBy(fields ...string) QueryBuilder + func (qb *MySQLQueryBuilder) Having(cond string) QueryBuilder + func (qb *MySQLQueryBuilder) In(vals ...string) QueryBuilder + func (qb *MySQLQueryBuilder) InnerJoin(table string) QueryBuilder + func (qb *MySQLQueryBuilder) InsertInto(table string, fields ...string) QueryBuilder + func (qb *MySQLQueryBuilder) LeftJoin(table string) QueryBuilder + func (qb *MySQLQueryBuilder) Limit(limit int) QueryBuilder + func (qb *MySQLQueryBuilder) Offset(offset int) QueryBuilder + func (qb *MySQLQueryBuilder) On(cond string) QueryBuilder + func (qb *MySQLQueryBuilder) Or(cond string) QueryBuilder + func (qb *MySQLQueryBuilder) OrderBy(fields ...string) QueryBuilder + func (qb *MySQLQueryBuilder) RightJoin(table string) QueryBuilder + func (qb *MySQLQueryBuilder) Select(fields ...string) QueryBuilder + func (qb *MySQLQueryBuilder) Set(kv ...string) QueryBuilder + func (qb *MySQLQueryBuilder) String() string + func (qb *MySQLQueryBuilder) Subquery(sub string, alias string) string + func (qb *MySQLQueryBuilder) Update(tables ...string) QueryBuilder + func (qb *MySQLQueryBuilder) Values(vals ...string) QueryBuilder + func (qb *MySQLQueryBuilder) Where(cond string) QueryBuilder + type Ormer interface + Begin func() error + BeginTx func(ctx context.Context, opts *sql.TxOptions) error + Commit func() error + DBStats func() *sql.DBStats + Delete func(md interface{}, cols ...string) (int64, error) + Driver func() Driver + Insert func(interface{}) (int64, error) + InsertMulti func(bulk int, mds interface{}) (int64, error) + InsertOrUpdate func(md interface{}, colConflitAndArgs ...string) (int64, error) + LoadRelated func(md interface{}, name string, args ...interface{}) (int64, error) + QueryM2M func(md interface{}, name string) QueryM2Mer + QueryTable func(ptrStructOrTableName interface{}) QuerySeter + Raw func(query string, args ...interface{}) RawSeter + Read func(md interface{}, cols ...string) error + ReadForUpdate func(md interface{}, cols ...string) error + ReadOrCreate func(md interface{}, col1 string, cols ...string) (bool, int64, error) + Rollback func() error + Update func(md interface{}, cols ...string) (int64, error) + Using func(name string) error + func NewOrm() Ormer + func NewOrmWithDB(driverName, aliasName string, db *sql.DB) (Ormer, error) + type Params map[string]interface + type ParamsList []interface + type PositiveBigIntegerField uint64 + func (e *PositiveBigIntegerField) FieldType() int + func (e *PositiveBigIntegerField) RawValue() interface{} + func (e *PositiveBigIntegerField) Set(d uint64) + func (e *PositiveBigIntegerField) SetRaw(value interface{}) error + func (e *PositiveBigIntegerField) String() string + func (e PositiveBigIntegerField) Value() uint64 + type PositiveIntegerField uint32 + func (e *PositiveIntegerField) FieldType() int + func (e *PositiveIntegerField) RawValue() interface{} + func (e *PositiveIntegerField) Set(d uint32) + func (e *PositiveIntegerField) SetRaw(value interface{}) error + func (e *PositiveIntegerField) String() string + func (e PositiveIntegerField) Value() uint32 + type PositiveSmallIntegerField uint16 + func (e *PositiveSmallIntegerField) FieldType() int + func (e *PositiveSmallIntegerField) RawValue() interface{} + func (e *PositiveSmallIntegerField) Set(d uint16) + func (e *PositiveSmallIntegerField) SetRaw(value interface{}) error + func (e *PositiveSmallIntegerField) String() string + func (e PositiveSmallIntegerField) Value() uint16 + type QueryBuilder interface + And func(cond string) QueryBuilder + Asc func() QueryBuilder + Delete func(tables ...string) QueryBuilder + Desc func() QueryBuilder + ForUpdate func() QueryBuilder + From func(tables ...string) QueryBuilder + GroupBy func(fields ...string) QueryBuilder + Having func(cond string) QueryBuilder + In func(vals ...string) QueryBuilder + InnerJoin func(table string) QueryBuilder + InsertInto func(table string, fields ...string) QueryBuilder + LeftJoin func(table string) QueryBuilder + Limit func(limit int) QueryBuilder + Offset func(offset int) QueryBuilder + On func(cond string) QueryBuilder + Or func(cond string) QueryBuilder + OrderBy func(fields ...string) QueryBuilder + RightJoin func(table string) QueryBuilder + Select func(fields ...string) QueryBuilder + Set func(kv ...string) QueryBuilder + String func() string + Subquery func(sub string, alias string) string + Update func(tables ...string) QueryBuilder + Values func(vals ...string) QueryBuilder + Where func(cond string) QueryBuilder + func NewQueryBuilder(driver string) (qb QueryBuilder, err error) + type QueryM2Mer interface + Add func(...interface{}) (int64, error) + Clear func() (int64, error) + Count func() (int64, error) + Exist func(interface{}) bool + Remove func(...interface{}) (int64, error) + type QuerySeter interface + All func(container interface{}, cols ...string) (int64, error) + Count func() (int64, error) + Delete func() (int64, error) + Distinct func() QuerySeter + Exclude func(string, ...interface{}) QuerySeter + Exist func() bool + Filter func(string, ...interface{}) QuerySeter + FilterRaw func(string, string) QuerySeter + ForUpdate func() QuerySeter + GetCond func() *Condition + GroupBy func(exprs ...string) QuerySeter + Limit func(limit interface{}, args ...interface{}) QuerySeter + Offset func(offset interface{}) QuerySeter + One func(container interface{}, cols ...string) error + OrderBy func(exprs ...string) QuerySeter + PrepareInsert func() (Inserter, error) + RelatedSel func(params ...interface{}) QuerySeter + RowsToMap func(result *Params, keyCol, valueCol string) (int64, error) + RowsToStruct func(ptrStruct interface{}, keyCol, valueCol string) (int64, error) + SetCond func(*Condition) QuerySeter + Update func(values Params) (int64, error) + Values func(results *[]Params, exprs ...string) (int64, error) + ValuesFlat func(result *ParamsList, expr string) (int64, error) + ValuesList func(results *[]ParamsList, exprs ...string) (int64, error) + type RawPreparer interface + Close func() error + Exec func(...interface{}) (sql.Result, error) + type RawSeter interface + Exec func() (sql.Result, error) + Prepare func() (RawPreparer, error) + QueryRow func(containers ...interface{}) error + QueryRows func(containers ...interface{}) (int64, error) + RowsToMap func(result *Params, keyCol, valueCol string) (int64, error) + RowsToStruct func(ptrStruct interface{}, keyCol, valueCol string) (int64, error) + SetArgs func(...interface{}) RawSeter + Values func(container *[]Params, cols ...string) (int64, error) + ValuesFlat func(container *ParamsList, cols ...string) (int64, error) + ValuesList func(container *[]ParamsList, cols ...string) (int64, error) + type SmallIntegerField int16 + func (e *SmallIntegerField) FieldType() int + func (e *SmallIntegerField) RawValue() interface{} + func (e *SmallIntegerField) Set(d int16) + func (e *SmallIntegerField) SetRaw(value interface{}) error + func (e *SmallIntegerField) String() string + func (e SmallIntegerField) Value() int16 + type StrTo string + func (f *StrTo) Clear() + func (f *StrTo) Set(v string) + func (f StrTo) Bool() (bool, error) + func (f StrTo) Exist() bool + func (f StrTo) Float32() (float32, error) + func (f StrTo) Float64() (float64, error) + func (f StrTo) Int() (int, error) + func (f StrTo) Int16() (int16, error) + func (f StrTo) Int32() (int32, error) + func (f StrTo) Int64() (int64, error) + func (f StrTo) Int8() (int8, error) + func (f StrTo) String() string + func (f StrTo) Uint() (uint, error) + func (f StrTo) Uint16() (uint16, error) + func (f StrTo) Uint32() (uint32, error) + func (f StrTo) Uint64() (uint64, error) + func (f StrTo) Uint8() (uint8, error) + type TextField string + func (e *TextField) FieldType() int + func (e *TextField) RawValue() interface{} + func (e *TextField) Set(d string) + func (e *TextField) SetRaw(value interface{}) error + func (e *TextField) String() string + func (e TextField) Value() string + type TiDBQueryBuilder struct + Tokens []string + func (qb *TiDBQueryBuilder) And(cond string) QueryBuilder + func (qb *TiDBQueryBuilder) Asc() QueryBuilder + func (qb *TiDBQueryBuilder) Delete(tables ...string) QueryBuilder + func (qb *TiDBQueryBuilder) Desc() QueryBuilder + func (qb *TiDBQueryBuilder) ForUpdate() QueryBuilder + func (qb *TiDBQueryBuilder) From(tables ...string) QueryBuilder + func (qb *TiDBQueryBuilder) GroupBy(fields ...string) QueryBuilder + func (qb *TiDBQueryBuilder) Having(cond string) QueryBuilder + func (qb *TiDBQueryBuilder) In(vals ...string) QueryBuilder + func (qb *TiDBQueryBuilder) InnerJoin(table string) QueryBuilder + func (qb *TiDBQueryBuilder) InsertInto(table string, fields ...string) QueryBuilder + func (qb *TiDBQueryBuilder) LeftJoin(table string) QueryBuilder + func (qb *TiDBQueryBuilder) Limit(limit int) QueryBuilder + func (qb *TiDBQueryBuilder) Offset(offset int) QueryBuilder + func (qb *TiDBQueryBuilder) On(cond string) QueryBuilder + func (qb *TiDBQueryBuilder) Or(cond string) QueryBuilder + func (qb *TiDBQueryBuilder) OrderBy(fields ...string) QueryBuilder + func (qb *TiDBQueryBuilder) RightJoin(table string) QueryBuilder + func (qb *TiDBQueryBuilder) Select(fields ...string) QueryBuilder + func (qb *TiDBQueryBuilder) Set(kv ...string) QueryBuilder + func (qb *TiDBQueryBuilder) String() string + func (qb *TiDBQueryBuilder) Subquery(sub string, alias string) string + func (qb *TiDBQueryBuilder) Update(tables ...string) QueryBuilder + func (qb *TiDBQueryBuilder) Values(vals ...string) QueryBuilder + func (qb *TiDBQueryBuilder) Where(cond string) QueryBuilder + type TimeField time.Time + func (e *TimeField) FieldType() int + func (e *TimeField) RawValue() interface{} + func (e *TimeField) Set(d time.Time) + func (e *TimeField) SetRaw(value interface{}) error + func (e *TimeField) String() string + func (e TimeField) Value() time.Time