Documentation
¶
Index ¶
- Constants
- func Count[T Model](ctx context.Context, conditions *Conditions) (num int64, err errors.CodeError)
- func Database(ctx context.Context, database string) context.Context
- func DefineSelectColumns(ctx context.Context, columns ...string) context.Context
- func DefinedSelectColumns(ctx context.Context) (columns []string, has bool)
- func Delete(ctx context.Context, model Model) (err errors.CodeError)
- func EagerLoad(ctx context.Context) context.Context
- func Exist[T Model](ctx context.Context, conditions *Conditions) (has bool, err errors.CodeError)
- func Insert(ctx context.Context, model Model) (err errors.CodeError)
- func InsertOrUpdate(ctx context.Context, model Model) (err errors.CodeError)
- func InsertWhenExist(ctx context.Context, model Model, source string) (err errors.CodeError)
- func InsertWhenNotExist(ctx context.Context, model Model, source string) (err errors.CodeError)
- func NotEagerLoad(ctx context.Context) context.Context
- func Query[T Model](ctx context.Context, conditions *Conditions) (results []T, err errors.CodeError)
- func QueryDirect[T Model](ctx context.Context, query string, args ...interface{}) (results []T, err errors.CodeError)
- func QueryOne[T Model](ctx context.Context, conditions *Conditions) (result T, err errors.CodeError)
- func QueryTree[T Model, N keyable](ctx context.Context, conditions *Conditions, orders *Orders, rng *Range, ...) (result T, err errors.CodeError)
- func QueryTrees[T Model, N keyable](ctx context.Context, conditions *Conditions, orders *Orders, rng *Range, ...) (results map[N]T, err errors.CodeError)
- func QueryWithRange[T Model](ctx context.Context, conditions *Conditions, orders *Orders, rng *Range) (results []T, err errors.CodeError)
- func RegisterDialectQueryGeneratorBuilder(dialect Dialect, builder DialectQueryGeneratorBuilder)
- func Update(ctx context.Context, model Model) (err errors.CodeError)
- type Condition
- func Between(column string, left interface{}, right interface{}) *Condition
- func BetweenDate(column string, dr *times.DateRange) *Condition
- func BetweenTime(column string, tr *times.TimeRange) *Condition
- func Eq(column string, value interface{}) *Condition
- func GT(column string, value interface{}) *Condition
- func GTE(column string, value interface{}) *Condition
- func IN(column string, value interface{}) *Condition
- func LT(column string, value interface{}) *Condition
- func LTE(column string, value interface{}) *Condition
- func Like(column string, value string) *Condition
- func LikeLeft(column string, value string) *Condition
- func LikeRight(column string, value string) *Condition
- func NewCondition(column string, operation string, arguments ...interface{}) *Condition
- func NotEq(column string, value interface{}) *Condition
- func NotIn(column string, value interface{}) *Condition
- type Conditions
- type Dialect
- type DialectQueryGeneratorBuilder
- type EagerLoader
- type Field
- func (field *Field) Column() (column string)
- func (field *Field) Columns() (columns []string)
- func (field *Field) Conflict() (ok bool)
- func (field *Field) HasColumns() (has bool)
- func (field *Field) IsACB() (ok bool)
- func (field *Field) IsACT() (ok bool)
- func (field *Field) IsADB() (ok bool)
- func (field *Field) IsADT() (ok bool)
- func (field *Field) IsAMB() (ok bool)
- func (field *Field) IsAMT() (ok bool)
- func (field *Field) IsAOL() (ok bool)
- func (field *Field) IsIncrPk() (ok bool)
- func (field *Field) IsJson() (ok bool)
- func (field *Field) IsLink() (ok bool)
- func (field *Field) IsNormal() (ok bool)
- func (field *Field) IsPk() (ok bool)
- func (field *Field) IsReference() (ok bool)
- func (field *Field) IsTreeType() (ok bool)
- func (field *Field) IsVirtual() (ok bool)
- func (field *Field) Link() (link *LinkField)
- func (field *Field) Model() (model *ModelStructure)
- func (field *Field) Name() (name string)
- func (field *Field) Reference() (reference *ReferenceField)
- func (field *Field) Tree() (tree *TreeNodeField)
- func (field *Field) Virtual() (virtual *VirtualField)
- type LinkField
- type Model
- type ModelLoadHook
- type ModelStructure
- func (structure *ModelStructure) AuditFields() (createBY *Field, createAT *Field, modifyBY *Field, modifyAT *Field, ...)
- func (structure *ModelStructure) Copy() (v *ModelStructure)
- func (structure *ModelStructure) DialectQueryGenerator(dialect Dialect) (queryGenerator QueryGenerator, err error)
- func (structure *ModelStructure) Fields() (fields []*Field)
- func (structure *ModelStructure) FindFieldByColumn(column string) (field *Field, has bool)
- func (structure *ModelStructure) IncrPk() (v *Field, has bool)
- func (structure *ModelStructure) Name() (schema string, name string)
- func (structure *ModelStructure) Pk() (fields []*Field, has bool)
- func (structure *ModelStructure) Type() (typ reflect.Type)
- type ModelStructureReferencePath
- type Order
- type Orders
- type PageRequest
- type Pager
- type QueryGenerator
- type QueryMethod
- type Range
- type ReferenceField
- type SubQueryArgument
- type TreeNodeField
- type VirtualField
Constants ¶
View Source
const ( QueryMode = QueryMethod("query") ExecuteMode = QueryMethod("execute") )
Variables ¶
This section is empty.
Functions ¶
func DefineSelectColumns ¶
func DefinedSelectColumns ¶
func InsertWhenExist ¶
func InsertWhenNotExist ¶
func QueryDirect ¶
func QueryTrees ¶
func QueryWithRange ¶
func RegisterDialectQueryGeneratorBuilder ¶
func RegisterDialectQueryGeneratorBuilder(dialect Dialect, builder DialectQueryGeneratorBuilder)
Types ¶
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
func NewCondition ¶
type Conditions ¶
type Conditions struct {
// contains filtered or unexported fields
}
func NewConditions ¶
func NewConditions(cond *Condition) *Conditions
func (*Conditions) And ¶
func (c *Conditions) And(v *Condition) *Conditions
func (*Conditions) AndConditions ¶
func (c *Conditions) AndConditions(v *Conditions) *Conditions
func (*Conditions) Or ¶
func (c *Conditions) Or(v *Condition) *Conditions
func (*Conditions) OrConditions ¶
func (c *Conditions) OrConditions(v *Conditions) *Conditions
func (*Conditions) Unfold ¶
func (c *Conditions) Unfold(head func(condition *Condition), nextCondition func(operator string, condition *Condition), nextConditions func(operator string, conditions *Conditions))
type DialectQueryGeneratorBuilder ¶
type DialectQueryGeneratorBuilder interface {
Build(structure *ModelStructure) (generator QueryGenerator, err error)
}
type EagerLoader ¶
type EagerLoader struct {
// contains filtered or unexported fields
}
func (*EagerLoader) AppendKey ¶
func (el *EagerLoader) AppendKey(key interface{})
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
func (*Field) HasColumns ¶
func (*Field) IsReference ¶
func (*Field) IsTreeType ¶
func (*Field) Model ¶
func (field *Field) Model() (model *ModelStructure)
func (*Field) Reference ¶
func (field *Field) Reference() (reference *ReferenceField)
func (*Field) Tree ¶
func (field *Field) Tree() (tree *TreeNodeField)
func (*Field) Virtual ¶
func (field *Field) Virtual() (virtual *VirtualField)
type LinkField ¶
type LinkField struct {
// contains filtered or unexported fields
}
func (*LinkField) Abstracted ¶
type ModelLoadHook ¶
type ModelStructure ¶
type ModelStructure struct {
// contains filtered or unexported fields
}
func StructureOfModel ¶
func StructureOfModel(model Model) (structure *ModelStructure, err error)
func (*ModelStructure) AuditFields ¶
func (*ModelStructure) Copy ¶
func (structure *ModelStructure) Copy() (v *ModelStructure)
func (*ModelStructure) DialectQueryGenerator ¶
func (structure *ModelStructure) DialectQueryGenerator(dialect Dialect) (queryGenerator QueryGenerator, err error)
func (*ModelStructure) Fields ¶
func (structure *ModelStructure) Fields() (fields []*Field)
func (*ModelStructure) FindFieldByColumn ¶
func (structure *ModelStructure) FindFieldByColumn(column string) (field *Field, has bool)
func (*ModelStructure) IncrPk ¶
func (structure *ModelStructure) IncrPk() (v *Field, has bool)
func (*ModelStructure) Name ¶
func (structure *ModelStructure) Name() (schema string, name string)
func (*ModelStructure) Pk ¶
func (structure *ModelStructure) Pk() (fields []*Field, has bool)
func (*ModelStructure) Type ¶
func (structure *ModelStructure) Type() (typ reflect.Type)
type ModelStructureReferencePath ¶
type ModelStructureReferencePath struct {
// contains filtered or unexported fields
}
type PageRequest ¶
type PageRequest struct {
// contains filtered or unexported fields
}
func NewPageRequest ¶
func NewPageRequest(no int, size int) *PageRequest
func (*PageRequest) MapToRange ¶
func (p *PageRequest) MapToRange() (rng *Range)
func (*PageRequest) Value ¶
func (p *PageRequest) Value() (no int, size int)
type Pager ¶
type QueryGenerator ¶
type QueryGenerator interface {
Insert(ctx context.Context, model Model) (method QueryMethod, query string, arguments []interface{}, err error)
InsertOrUpdate(ctx context.Context, model Model) (method QueryMethod, query string, arguments []interface{}, err error)
InsertWhenExist(ctx context.Context, model Model, source string) (method QueryMethod, query string, arguments []interface{}, err error)
InsertWhenNotExist(ctx context.Context, model Model, source string) (method QueryMethod, query string, arguments []interface{}, err error)
Update(ctx context.Context, model Model) (method QueryMethod, query string, arguments []interface{}, err error)
Delete(ctx context.Context, model Model) (method QueryMethod, query string, arguments []interface{}, err error)
Exist(ctx context.Context, cond *Conditions) (method QueryMethod, query string, arguments []interface{}, err error)
Count(ctx context.Context, cond *Conditions) (method QueryMethod, query string, arguments []interface{}, err error)
Query(ctx context.Context, cond *Conditions, orders *Orders, rng *Range) (method QueryMethod, query string, arguments []interface{}, err error)
}
type QueryMethod ¶
type QueryMethod string
type Range ¶
type Range struct {
// contains filtered or unexported fields
}
func (*Range) MapToPageRequest ¶
func (rng *Range) MapToPageRequest() (pager *PageRequest)
type ReferenceField ¶
type ReferenceField struct {
// contains filtered or unexported fields
}
func (*ReferenceField) Abstracted ¶
func (r *ReferenceField) Abstracted() (ok bool)
func (*ReferenceField) Name ¶
func (r *ReferenceField) Name() (name string)
func (*ReferenceField) Target ¶
func (r *ReferenceField) Target() (targetModel *ModelStructure, targetFields []*Field, columns []string)
type SubQueryArgument ¶
type SubQueryArgument struct {
// contains filtered or unexported fields
}
func NewSubQueryArgument ¶
func NewSubQueryArgument(model Model, column string, conditions *Conditions) *SubQueryArgument
func (*SubQueryArgument) GenerateQueryFragment ¶
type TreeNodeField ¶
type TreeNodeField struct {
// contains filtered or unexported fields
}
func (*TreeNodeField) RefColumnName ¶
func (t *TreeNodeField) RefColumnName() (node string, parent string)
type VirtualField ¶
type VirtualField struct {
// contains filtered or unexported fields
}
func (*VirtualField) Name ¶
func (v *VirtualField) Name() (name string)
func (*VirtualField) Query ¶
func (v *VirtualField) Query() (query string)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.