Documentation ¶
Index ¶
- Constants
- Variables
- func Clone(ctx context.Context, configName string, w CloneWrapper) (result sql.Result, err error)
- func Delete(ctx context.Context, configName string, w DeleteWrapper) (result sql.Result, err error)
- func InitConfig(config ...Config) error
- func Insert(ctx context.Context, configName string, w InsertWrapper) (result sql.Result, err error)
- func JoinFieldNames(fields []FieldName, sep string) string
- func Now() int64
- func QueryScan(ctx context.Context, configName string, out interface{}, statement string, ...) error
- func Select(ctx context.Context, configName string, w QueryWrapper, out interface{}) error
- func Update(ctx context.Context, configName string, w UpdateWrapper) (result sql.Result, err error)
- type CloneWrapper
- type Column
- type Condition
- type ConditionLogic
- type Config
- type DataSet
- type DeleteWrapper
- type FieldName
- type H
- type IManager
- type InsertWrapper
- type Join
- type JoinStatement
- type Model
- type Order
- type QueryWrapper
- type Row
- type TableName
- type TableNameList
- type UpdateExpression
- func NewDuplicatedUpdateExpression(fields ...FieldName) UpdateExpression
- func NewIncreaseExpression(field FieldName, value interface{}) UpdateExpression
- func NewSetValueUpdateExpression(field FieldName, value interface{}) UpdateExpression
- func NewUpdateExpression(modelOrMap interface{}, ignoreFields ...FieldName) UpdateExpression
- type UpdateWrapper
- type WhereWrapper
Constants ¶
View Source
const ( JoinStatementLeftJoin = JoinStatement("LEFT JOIN") JoinStatementRightJoin = JoinStatement("RIGHT JOIN") )
View Source
const ( ConditionLogicAnd = ConditionLogic("AND") ConditionLogicOr = ConditionLogic("OR") )
View Source
const DefaultInsertBatchSize = 1000
View Source
const DefaultName = "default"
View Source
const DefaultRetry = 3
Variables ¶
View Source
var TablePrefix = ""
Functions ¶
func InitConfig ¶
func JoinFieldNames ¶
Types ¶
type CloneWrapper ¶
func NewCloneWrapper ¶
func NewCloneWrapper(templateTableName, newTableName TableName) CloneWrapper
type Condition ¶
type Condition interface { Clone() Condition Build() (statement string, values []interface{}, err error) }
func NewExpressionCondition ¶
func NewNestedCondition ¶
func NewNestedCondition(w WhereWrapper) Condition
func NewNotNullCondition ¶
func NewNullCondition ¶
type ConditionLogic ¶
type ConditionLogic string
type DeleteWrapper ¶
type DeleteWrapper interface { Model(model interface{}) DeleteWrapper WhereWrapper TableName(tableName TableName) DeleteWrapper Build() (statement string, values []interface{}, err error) }
func NewDeleteWrapper ¶
func NewDeleteWrapper(model ...interface{}) DeleteWrapper
type FieldName ¶
type FieldName string
func (FieldName) LowerFirstHump ¶
func (FieldName) UpperFirstHump ¶
func (FieldName) WithTableAlias ¶
type IManager ¶
type IManager interface { Add(c Config) error Exec(ctx context.Context, configName string, statement string, values ...interface{}) (result sql.Result, err error) Query(ctx context.Context, configName string, statement string, values ...interface{}) (result *sql.Rows, err error) QueryRows(ctx context.Context, configName string, statement string, values ...interface{}) (DataSet, error) // contains filtered or unexported methods }
func NewConnManager ¶
func NewConnManager() IManager
type InsertWrapper ¶
type InsertWrapper interface { Model(v interface{}) InsertWrapper BatchSize(batchSize int) InsertWrapper Fields(fields ...FieldName) InsertWrapper DataLen() int Reset() InsertWrapper Build() (statement string, values []interface{}, next bool, err error) Ignore() InsertWrapper Add(v ...interface{}) InsertWrapper OnDuplicatedUpdate(field FieldName, values ...interface{}) InsertWrapper }
func NewInsertWrapper ¶
func NewInsertWrapper(model ...interface{}) InsertWrapper
type Join ¶
type Join struct { Statement JoinStatement TableName TableName WhereWrapper WhereWrapper }
type JoinStatement ¶
type JoinStatement string
type Model ¶
func CreateModel ¶
func CreateModel(model interface{}) Model
type QueryWrapper ¶
type QueryWrapper interface { TableName(tb TableName) QueryWrapper Model(v interface{}) QueryWrapper WhereWrapper OrderDesc(fields ...FieldName) QueryWrapper OrderAsc(fields ...FieldName) QueryWrapper Order(orderBy ...Order) QueryWrapper Offset(offset int64) QueryWrapper Limit(limit int64) QueryWrapper Page(pageNum, pageSize int64) QueryWrapper Select(fields ...FieldName) QueryWrapper LeftJoin(tableName TableName, where WhereWrapper) QueryWrapper RightJoin(tableName TableName, where WhereWrapper) QueryWrapper SetWhere(where WhereWrapper) QueryWrapper }
func NewQueryWrapper ¶
func NewQueryWrapper(model ...interface{}) QueryWrapper
type TableNameList ¶
type TableNameList []TableName
func ShowTables ¶
func ShowTables(ctx context.Context, configName string) (tableNameList TableNameList, err error)
func (TableNameList) Contain ¶
func (t TableNameList) Contain(tb TableName) bool
type UpdateExpression ¶
type UpdateExpression interface { Build() (statement string, values []interface{}, err error) Clone() UpdateExpression }
func NewDuplicatedUpdateExpression ¶
func NewDuplicatedUpdateExpression(fields ...FieldName) UpdateExpression
func NewIncreaseExpression ¶
func NewIncreaseExpression(field FieldName, value interface{}) UpdateExpression
func NewSetValueUpdateExpression ¶
func NewSetValueUpdateExpression(field FieldName, value interface{}) UpdateExpression
func NewUpdateExpression ¶
func NewUpdateExpression(modelOrMap interface{}, ignoreFields ...FieldName) UpdateExpression
type UpdateWrapper ¶
type UpdateWrapper interface { Model(v interface{}) UpdateWrapper WhereWrapper LeftJoin(tableName TableName, where WhereWrapper) UpdateWrapper RightJoin(tableName TableName, where WhereWrapper) UpdateWrapper SetValue(field FieldName, value interface{}) UpdateWrapper SetExpression(expressions ...UpdateExpression) UpdateWrapper Inc(field FieldName, value interface{}) UpdateWrapper Updates(object interface{}, ignoreFields ...FieldName) UpdateWrapper Build() (statement string, values []interface{}, err error) Table(tableName TableName) UpdateWrapper SetWhere(w WhereWrapper) UpdateWrapper }
func NewUpdateWrapper ¶
func NewUpdateWrapper(model ...interface{}) UpdateWrapper
type WhereWrapper ¶
type WhereWrapper interface { Eq(field FieldName, v interface{}) WhereWrapper Neq(field FieldName, v interface{}) WhereWrapper Le(field FieldName, v interface{}) WhereWrapper Lt(field FieldName, v interface{}) WhereWrapper Gt(field FieldName, v interface{}) WhereWrapper Ge(field FieldName, v interface{}) WhereWrapper In(field FieldName, v interface{}) WhereWrapper NotIn(field FieldName, v interface{}) WhereWrapper IsNotNull(field FieldName) WhereWrapper IsNull(field FieldName) WhereWrapper Nested(w WhereWrapper) WhereWrapper Like(field FieldName, v interface{}) WhereWrapper Clone() WhereWrapper Build() (string, []interface{}, error) }
func NewAndWhereWrapper ¶
func NewAndWhereWrapper() WhereWrapper
func NewOrWhereWrapper ¶
func NewOrWhereWrapper() WhereWrapper
Click to show internal directories.
Click to hide internal directories.