Versions in this module Expand all Collapse all v1 v1.0.2 Mar 14, 2024 v1.0.1 Mar 14, 2024 Changes in this version + const ColAdd + const ColBitAnd + const ColBitLShift + const ColBitOr + const ColBitRShift + const ColBitXOR + 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 TxNameKey + 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 = iutils.DefaultTimeLoc + var ErrArgs = errors.New("<Ormer> args error may be empty") + var ErrLastInsertIdUnavailable = errors.New("<Ormer> last insert id is unavailable") + 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("<TxOrmer.Commit/Rollback> transaction already done") + var LogFunc func(query map[string]interface{}) + func AddAliasWthDB(aliasName, driverName string, db *sql.DB, params ...DBOption) error + func AddGlobalFilterChain(filterChain ...FilterChain) + func BootStrap() + func ColValue(opt operator, value interface{}) interface + func GetDB(aliasNames ...string) (*sql.DB, error) + func NewLog(out io.Writer) *logs.Log + func RegisterDataBase(aliasName, driverName, dataSource string, params ...DBOption) 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) + type BigIntegerField = models.BigIntegerField + type BooleanField = models.BooleanField + type CharField = models.CharField + 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 DBOption func(al *alias) + func ConnMaxIdletime(v time.Duration) DBOption + func ConnMaxLifetime(v time.Duration) DBOption + func MaxIdleConnections(maxIdleConn int) DBOption + func MaxOpenConnections(maxOpenConn int) DBOption + func MaxStmtCacheSize(v int) DBOption + type DML interface + Delete func(md interface{}, cols ...string) (int64, error) + DeleteWithCtx func(ctx context.Context, md interface{}, cols ...string) (int64, error) + Insert func(md interface{}) (int64, error) + InsertMulti func(bulk int, mds interface{}) (int64, error) + InsertMultiWithCtx func(ctx context.Context, bulk int, mds interface{}) (int64, error) + InsertOrUpdate func(md interface{}, colConflitAndArgs ...string) (int64, error) + InsertOrUpdateWithCtx func(ctx context.Context, md interface{}, colConflitAndArgs ...string) (int64, error) + InsertWithCtx func(ctx context.Context, md interface{}) (int64, error) + Raw func(query string, args ...interface{}) RawSeter + RawWithCtx func(ctx context.Context, query string, args ...interface{}) RawSeter + Update func(md interface{}, cols ...string) (int64, error) + UpdateWithCtx func(ctx context.Context, md interface{}, cols ...string) (int64, error) + type DQL interface + DBStats func() *sql.DBStats + LoadRelated func(md interface{}, name string, args ...utils.KV) (int64, error) + LoadRelatedWithCtx func(ctx context.Context, md interface{}, name string, args ...utils.KV) (int64, error) + QueryM2M func(md interface{}, name string) QueryM2Mer + QueryM2MWithCtx func(ctx context.Context, md interface{}, name string) QueryM2Mer + QueryTable func(ptrStructOrTableName interface{}) QuerySeter + QueryTableWithCtx func(ctx context.Context, ptrStructOrTableName interface{}) QuerySeter + Read func(md interface{}, cols ...string) error + ReadForUpdate func(md interface{}, cols ...string) error + ReadForUpdateWithCtx func(ctx context.Context, md interface{}, cols ...string) error + ReadOrCreate func(md interface{}, col1 string, cols ...string) (bool, int64, error) + ReadOrCreateWithCtx func(ctx context.Context, md interface{}, col1 string, cols ...string) (bool, int64, error) + ReadWithCtx func(ctx context.Context, md interface{}, cols ...string) error + type DateField = models.DateField + type DateTimeField = models.DateTimeField + type DoNothingOrm struct + func (d *DoNothingOrm) Begin() (TxOrmer, error) + func (d *DoNothingOrm) BeginWithCtx(ctx context.Context) (TxOrmer, error) + func (d *DoNothingOrm) BeginWithCtxAndOpts(ctx context.Context, opts *sql.TxOptions) (TxOrmer, error) + func (d *DoNothingOrm) BeginWithOpts(opts *sql.TxOptions) (TxOrmer, error) + func (d *DoNothingOrm) DBStats() *sql.DBStats + func (d *DoNothingOrm) Delete(md interface{}, cols ...string) (int64, error) + func (d *DoNothingOrm) DeleteWithCtx(ctx context.Context, md interface{}, cols ...string) (int64, error) + func (d *DoNothingOrm) DoTx(task func(ctx context.Context, txOrm TxOrmer) error) error + func (d *DoNothingOrm) DoTxWithCtx(ctx context.Context, task func(ctx context.Context, txOrm TxOrmer) error) error + func (d *DoNothingOrm) DoTxWithCtxAndOpts(ctx context.Context, opts *sql.TxOptions, ...) error + func (d *DoNothingOrm) DoTxWithOpts(opts *sql.TxOptions, task func(ctx context.Context, txOrm TxOrmer) error) error + func (d *DoNothingOrm) Driver() Driver + func (d *DoNothingOrm) Insert(md interface{}) (int64, error) + func (d *DoNothingOrm) InsertMulti(bulk int, mds interface{}) (int64, error) + func (d *DoNothingOrm) InsertMultiWithCtx(ctx context.Context, bulk int, mds interface{}) (int64, error) + func (d *DoNothingOrm) InsertOrUpdate(md interface{}, colConflitAndArgs ...string) (int64, error) + func (d *DoNothingOrm) InsertOrUpdateWithCtx(ctx context.Context, md interface{}, colConflitAndArgs ...string) (int64, error) + func (d *DoNothingOrm) InsertWithCtx(ctx context.Context, md interface{}) (int64, error) + func (d *DoNothingOrm) LoadRelated(md interface{}, name string, args ...utils.KV) (int64, error) + func (d *DoNothingOrm) LoadRelatedWithCtx(ctx context.Context, md interface{}, name string, args ...utils.KV) (int64, error) + func (d *DoNothingOrm) QueryM2M(md interface{}, name string) QueryM2Mer + func (d *DoNothingOrm) QueryM2MWithCtx(ctx context.Context, md interface{}, name string) QueryM2Mer + func (d *DoNothingOrm) QueryTable(ptrStructOrTableName interface{}) QuerySeter + func (d *DoNothingOrm) QueryTableWithCtx(ctx context.Context, ptrStructOrTableName interface{}) QuerySeter + func (d *DoNothingOrm) Raw(query string, args ...interface{}) RawSeter + func (d *DoNothingOrm) RawWithCtx(ctx context.Context, query string, args ...interface{}) RawSeter + func (d *DoNothingOrm) Read(md interface{}, cols ...string) error + func (d *DoNothingOrm) ReadForUpdate(md interface{}, cols ...string) error + func (d *DoNothingOrm) ReadForUpdateWithCtx(ctx context.Context, md interface{}, cols ...string) error + func (d *DoNothingOrm) ReadOrCreate(md interface{}, col1 string, cols ...string) (bool, int64, error) + func (d *DoNothingOrm) ReadOrCreateWithCtx(ctx context.Context, md interface{}, col1 string, cols ...string) (bool, int64, error) + func (d *DoNothingOrm) ReadWithCtx(ctx context.Context, md interface{}, cols ...string) error + func (d *DoNothingOrm) Update(md interface{}, cols ...string) (int64, error) + func (d *DoNothingOrm) UpdateWithCtx(ctx context.Context, md interface{}, cols ...string) (int64, error) + type DoNothingTxOrm struct + func (d *DoNothingTxOrm) Commit() error + func (d *DoNothingTxOrm) Rollback() error + type Driver interface + Name func() string + Type func() DriverType + type DriverGetter interface + Driver func() Driver + type DriverType int + const DRMySQL + const DROracle + const DRPostgres + const DRSqlite + const DRTiDB + type Fielder = models.Fielder + type Filter func(ctx context.Context, inv *Invocation) []interface + type FilterChain func(next Filter) Filter + type FloatField = models.FloatField + type Inserter interface + Close func() error + Insert func(interface{}) (int64, error) + InsertWithCtx func(context.Context, interface{}) (int64, error) + type IntegerField = models.IntegerField + type Invocation struct + Args []interface{} + InsideTx bool + Md interface{} + Method string + TxName string + TxStartTime time.Time + func (inv *Invocation) GetPkFieldName() string + func (inv *Invocation) GetTableName() string + type IsApplicableTableForDB interface + IsApplicableTableForDB func(db string) bool + type JSONField = models.JSONField + type JsonbField = models.JsonbField + type Log = logs.Log + type MySQLQueryBuilder struct + 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 + func NewFilterOrmDecorator(delegate Ormer, filterChains ...FilterChain) Ormer + func NewOrm() Ormer + func NewOrmUsingDB(aliasName string) Ormer + func NewOrmWithDB(driverName, aliasName string, db *sql.DB, params ...DBOption) (Ormer, error) + type Params map[string]interface + type ParamsList []interface + type PositiveBigIntegerField = models.PositiveBigIntegerField + type PositiveIntegerField = models.PositiveIntegerField + type PositiveSmallIntegerField = models.PositiveSmallIntegerField + type PostgresQueryBuilder struct + func (qb *PostgresQueryBuilder) And(cond string) QueryBuilder + func (qb *PostgresQueryBuilder) Asc() QueryBuilder + func (qb *PostgresQueryBuilder) Delete(tables ...string) QueryBuilder + func (qb *PostgresQueryBuilder) Desc() QueryBuilder + func (qb *PostgresQueryBuilder) ForUpdate() QueryBuilder + func (qb *PostgresQueryBuilder) From(tables ...string) QueryBuilder + func (qb *PostgresQueryBuilder) GroupBy(fields ...string) QueryBuilder + func (qb *PostgresQueryBuilder) Having(cond string) QueryBuilder + func (qb *PostgresQueryBuilder) In(vals ...string) QueryBuilder + func (qb *PostgresQueryBuilder) InnerJoin(table string) QueryBuilder + func (qb *PostgresQueryBuilder) InsertInto(table string, fields ...string) QueryBuilder + func (qb *PostgresQueryBuilder) LeftJoin(table string) QueryBuilder + func (qb *PostgresQueryBuilder) Limit(limit int) QueryBuilder + func (qb *PostgresQueryBuilder) Offset(offset int) QueryBuilder + func (qb *PostgresQueryBuilder) On(cond string) QueryBuilder + func (qb *PostgresQueryBuilder) Or(cond string) QueryBuilder + func (qb *PostgresQueryBuilder) OrderBy(fields ...string) QueryBuilder + func (qb *PostgresQueryBuilder) RightJoin(table string) QueryBuilder + func (qb *PostgresQueryBuilder) Select(fields ...string) QueryBuilder + func (qb *PostgresQueryBuilder) Set(kv ...string) QueryBuilder + func (qb *PostgresQueryBuilder) String() string + func (qb *PostgresQueryBuilder) Subquery(sub string, alias string) string + func (qb *PostgresQueryBuilder) Update(tables ...string) QueryBuilder + func (qb *PostgresQueryBuilder) Values(vals ...string) QueryBuilder + func (qb *PostgresQueryBuilder) Where(cond string) QueryBuilder + 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 QueryExecutor interface + type QueryM2Mer interface + Add func(...interface{}) (int64, error) + AddWithCtx func(context.Context, ...interface{}) (int64, error) + Clear func() (int64, error) + ClearWithCtx func(context.Context) (int64, error) + Count func() (int64, error) + CountWithCtx func(context.Context) (int64, error) + Exist func(interface{}) bool + ExistWithCtx func(context.Context, interface{}) bool + Remove func(...interface{}) (int64, error) + RemoveWithCtx func(context.Context, ...interface{}) (int64, error) + type QuerySeter interface + Aggregate func(s string) QuerySeter + All func(container interface{}, cols ...string) (int64, error) + AllWithCtx func(ctx context.Context, container interface{}, cols ...string) (int64, error) + Count func() (int64, error) + CountWithCtx func(context.Context) (int64, error) + Delete func() (int64, error) + DeleteWithCtx func(context.Context) (int64, error) + Distinct func() QuerySeter + Exclude func(string, ...interface{}) QuerySeter + Exist func() bool + ExistWithCtx func(context.Context) bool + Filter func(string, ...interface{}) QuerySeter + FilterRaw func(string, string) QuerySeter + ForUpdate func() QuerySeter + ForceIndex func(indexes ...string) QuerySeter + GetCond func() *Condition + GroupBy func(exprs ...string) QuerySeter + IgnoreIndex func(indexes ...string) QuerySeter + Limit func(limit interface{}, args ...interface{}) QuerySeter + Offset func(offset interface{}) QuerySeter + One func(container interface{}, cols ...string) error + OneWithCtx func(ctx context.Context, container interface{}, cols ...string) error + OrderBy func(exprs ...string) QuerySeter + OrderClauses func(orders ...*order_clause.Order) QuerySeter + PrepareInsert func() (Inserter, error) + PrepareInsertWithCtx func(context.Context) (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) + UpdateWithCtx func(ctx context.Context, values Params) (int64, error) + UseIndex func(indexes ...string) QuerySeter + Values func(results *[]Params, exprs ...string) (int64, error) + ValuesFlat func(result *ParamsList, expr string) (int64, error) + ValuesFlatWithCtx func(ctx context.Context, result *ParamsList, expr string) (int64, error) + ValuesList func(results *[]ParamsList, exprs ...string) (int64, error) + ValuesListWithCtx func(ctx context.Context, results *[]ParamsList, exprs ...string) (int64, error) + ValuesWithCtx func(ctx context.Context, results *[]Params, 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 = models.SmallIntegerField + type StrTo = utils.StrTo + type TableEngineI interface + TableEngine func() string + type TableIndexI interface + TableIndex func() [][]string + type TableNameI interface + TableName func() string + type TableUniqueI interface + TableUnique func() [][]string + type TextField = models.TextField + type TiDBQueryBuilder struct + type TimeField = models.TimeField + type TxBeginner interface + Begin func() (TxOrmer, error) + BeginWithCtx func(ctx context.Context) (TxOrmer, error) + BeginWithCtxAndOpts func(ctx context.Context, opts *sql.TxOptions) (TxOrmer, error) + BeginWithOpts func(opts *sql.TxOptions) (TxOrmer, error) + DoTx func(task func(ctx context.Context, txOrm TxOrmer) error) error + DoTxWithCtx func(ctx context.Context, task func(ctx context.Context, txOrm TxOrmer) error) error + DoTxWithCtxAndOpts func(ctx context.Context, opts *sql.TxOptions, ...) error + DoTxWithOpts func(opts *sql.TxOptions, task func(ctx context.Context, txOrm TxOrmer) error) error + type TxCommitter interface + type TxDB struct + func (t *TxDB) Commit() error + func (t *TxDB) Exec(query string, args ...interface{}) (sql.Result, error) + func (t *TxDB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + func (t *TxDB) Prepare(query string) (*sql.Stmt, error) + func (t *TxDB) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) + func (t *TxDB) Query(query string, args ...interface{}) (*sql.Rows, error) + func (t *TxDB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + func (t *TxDB) QueryRow(query string, args ...interface{}) *sql.Row + func (t *TxDB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row + func (t *TxDB) Rollback() error + func (t *TxDB) RollbackUnlessCommit() error + type TxOrmer interface + func NewFilterTxOrmDecorator(delegate TxOrmer, root Filter, txName string) TxOrmer