Documentation ¶
Index ¶
- Variables
- type Direction
- type Filter
- func (f *Filter) FieldName() string
- func (f *Filter) FillValue(values []any) error
- func (f *Filter) FilterModifier() *FilterModifier
- func (f *Filter) NamedArgs() []string
- func (f *Filter) NumValue() (num int)
- func (f *Filter) Predicate() *Predicate
- func (f Filter) String() string
- func (f *Filter) Values() []any
- type FilterGroup
- type FilterModifier
- type FilterOption
- type LogicOperator
- type Option
- func WithFilterGroup(filterGroup *FilterGroup) Option
- func WithPager(pager Pager) Option
- func WithSorts(sorts []*Sort) Option
- func WithSubjectModifier(modifier *SubjectModifier) Option
- func WithSubjectModifierArgs(subjectModifierArgs map[SubjectModifierArg]any) Option
- func WithTable(table Table) Option
- type PageRequest
- func (p *PageRequest) Offset() int
- func (p *PageRequest) Page() int
- func (p *PageRequest) PageSize() int
- func (p *PageRequest) SearchCount() bool
- func (p *PageRequest) SetPage(page int)
- func (p *PageRequest) SetPageSize(pageSize int)
- func (p *PageRequest) SetSearchCount(searchCount bool)
- func (p PageRequest) String() string
- type Pager
- type Predicate
- type Query
- func (q *Query) FilterGroup() *FilterGroup
- func (q *Query) Pager() Pager
- func (q *Query) Sorts() []*Sort
- func (q Query) String() string
- func (q *Query) Subject() *Subject
- func (q *Query) SubjectModifier() *SubjectModifier
- func (q *Query) SubjectModifierArgs() map[SubjectModifierArg]any
- func (q *Query) Table() Table
- func (q *Query) With(opts ...Option) *Query
- type RDBTranslator
- func (t *RDBTranslator) Translate(ctx context.Context, query *Query) (result string, err error)
- func (t *RDBTranslator) TranslateCount(ctx context.Context, query *Query) (result string, err error)
- func (t *RDBTranslator) TranslateDelete(ctx context.Context, query *Query) (result string, err error)
- func (t *RDBTranslator) TranslateExists(ctx context.Context, query *Query) (result string, err error)
- func (t *RDBTranslator) TranslateFilter(ctx context.Context, f *Filter) (result string, err error)
- func (t *RDBTranslator) TranslateFilterGroup(ctx context.Context, fg *FilterGroup) (result string, err error)
- func (t *RDBTranslator) TranslateFind(ctx context.Context, query *Query) (result string, err error)
- func (t *RDBTranslator) TranslateLogicOperator(ctx context.Context, operator LogicOperator) (result string, err error)
- func (t *RDBTranslator) TranslatePager(ctx context.Context, pager Pager) (result string, err error)
- func (t *RDBTranslator) TranslateSort(ctx context.Context, sort *Sort) (result string, err error)
- func (t *RDBTranslator) TranslateSorts(ctx context.Context, sorts []*Sort) (result string, err error)
- func (t *RDBTranslator) TranslateTable(ctx context.Context, table Table) (string, error)
- type Sort
- type Subject
- type SubjectModifier
- type SubjectModifierArg
- type Table
- type TableOption
- type Translator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( PredicateContains = &Predicate{keywords: []string{"Contains"}, numArgs: 1} PredicateStartsWith = &Predicate{keywords: []string{"StartsWith"}, numArgs: 1} PredicateEndsWith = &Predicate{keywords: []string{"EndsWith"}, numArgs: 1} PredicateIsNull = &Predicate{keywords: []string{"IsNull"}, numArgs: 0} PredicateIsNotNull = &Predicate{keywords: []string{"IsNotNull"}, numArgs: 0} //PredicateIsEmpty is collection empty, //If you want to express that the string is not empty, you can use 'Is', //and then use an empty string as a parameter, the same below PredicateIsEmpty = &Predicate{keywords: []string{"IsEmpty"}, numArgs: 0} //PredicateIsNotEmpty is collection not empty PredicateIsNotEmpty = &Predicate{keywords: []string{"IsNotEmpty"}, numArgs: 0} PredicateIsFalse = &Predicate{keywords: []string{"IsFalse"}, numArgs: 0} PredicateIsTrue = &Predicate{keywords: []string{"IsTrue"}, numArgs: 0} PredicateMatches = &Predicate{keywords: []string{"Matches"}, numArgs: 1} //PredicateBetween The BETWEEN operator is inclusive: begin and end values are included. PredicateBetween = &Predicate{keywords: []string{"Between"}, numArgs: 2} PredicateNotIn = &Predicate{keywords: []string{"NotIn"}, numArgs: 1} PredicateIn = &Predicate{keywords: []string{"In"}, numArgs: 1} PredicateGT = &Predicate{keywords: []string{"GT"}, numArgs: 1} PredicateLT = &Predicate{keywords: []string{"LT"}, numArgs: 1} PredicateGTE = &Predicate{keywords: []string{"GTE"}, numArgs: 1} PredicateLTE = &Predicate{keywords: []string{"LTE"}, numArgs: 1} PredicateIsNot = &Predicate{keywords: []string{"IsNot", "NotEquals", "NE"}, numArgs: 1} PredicateIs = &Predicate{keywords: []string{"Equals", "Is", "EQ", ""}, numArgs: 1} )
View Source
var ( FilterModifierIgnoreCase = &FilterModifier{keywords: []string{"IgnoreCase", "IC"}, global: false} FilterModifierAllIgnoreCase = &FilterModifier{keywords: []string{"AllIgnoreCase", "AllIC"}, global: true} )
View Source
var ( SubjectFind = &Subject{keywords: []string{"Find", "Query", "Get", "Search"}, sortable: true} SubjectCount = &Subject{keywords: []string{"Count"}, sortable: false} SubjectExists = &Subject{keywords: []string{"Exists"}, sortable: false} SubjectDelete = &Subject{keywords: []string{"Delete", "Remove"}, sortable: true} )
View Source
var ( SubjectModifierDistinct = &SubjectModifier{ keywords: []string{"Distinct"}, subjects: map[*Subject]bool{SubjectFind: true, SubjectCount: true}, } SubjectModifierTop = &SubjectModifier{ keywords: []string{"Top"}, subjects: map[*Subject]bool{SubjectFind: true, SubjectDelete: true}, } )
View Source
var FilterModifiers = []*FilterModifier{ FilterModifierIgnoreCase, FilterModifierAllIgnoreCase, }
View Source
var Predicates = []*Predicate{ PredicateContains, PredicateStartsWith, PredicateEndsWith, PredicateIsNull, PredicateIsNotNull, PredicateIsEmpty, PredicateIsNotEmpty, PredicateIsFalse, PredicateIsTrue, PredicateMatches, PredicateBetween, PredicateNotIn, PredicateIn, PredicateGT, PredicateLT, PredicateGTE, PredicateLTE, PredicateIsNot, PredicateIs, }
View Source
var SubjectModifiers = []*SubjectModifier{ SubjectModifierDistinct, SubjectModifierTop, }
View Source
var Subjects = []*Subject{ SubjectFind, SubjectCount, SubjectExists, SubjectDelete, }
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
func NewFilter ¶
func NewFilter(fieldName string, predicate *Predicate, opts ...FilterOption) *Filter
func (*Filter) FilterModifier ¶
func (f *Filter) FilterModifier() *FilterModifier
type FilterGroup ¶
type FilterGroup struct {
// contains filtered or unexported fields
}
func NewFilterGroup ¶
func NewFilterGroup(groups []*FilterGroup, logicOperator LogicOperator) *FilterGroup
func NewFilterGroupWithFilters ¶
func NewFilterGroupWithFilters(filters []*Filter, logicOperator LogicOperator) *FilterGroup
func (*FilterGroup) FillNamedArgs ¶
func (fg *FilterGroup) FillNamedArgs(namedArgs []string) error
func (*FilterGroup) FillValues ¶
func (fg *FilterGroup) FillValues(values []any) error
func (*FilterGroup) IsEmpty ¶
func (fg *FilterGroup) IsEmpty() bool
func (*FilterGroup) NumValue ¶
func (fg *FilterGroup) NumValue() (num int)
func (FilterGroup) String ¶
func (fg FilterGroup) String() string
type FilterModifier ¶
type FilterModifier struct {
// contains filtered or unexported fields
}
func (*FilterModifier) Global ¶
func (p *FilterModifier) Global() bool
func (*FilterModifier) Keywords ¶
func (p *FilterModifier) Keywords() []string
func (FilterModifier) String ¶
func (p FilterModifier) String() string
type FilterOption ¶
type FilterOption func(filter *Filter)
func WithFilterModifier ¶
func WithFilterModifier(modifier *FilterModifier) FilterOption
func WithFilterNamedArgs ¶
func WithFilterNamedArgs(namedArgs ...string) FilterOption
func WithFilterValues ¶
func WithFilterValues(values ...any) FilterOption
type LogicOperator ¶
type LogicOperator string
const ( LogicOperatorAnd LogicOperator = "And" LogicOperatorOr LogicOperator = "Or" )
func (LogicOperator) String ¶
func (l LogicOperator) String() string
type Option ¶
type Option func(q *Query)
func WithFilterGroup ¶
func WithFilterGroup(filterGroup *FilterGroup) Option
func WithSubjectModifier ¶
func WithSubjectModifier(modifier *SubjectModifier) Option
func WithSubjectModifierArgs ¶
func WithSubjectModifierArgs(subjectModifierArgs map[SubjectModifierArg]any) Option
type PageRequest ¶
type PageRequest struct {
// contains filtered or unexported fields
}
func NewPageRequest ¶
func NewPageRequest(page int, pageSize int, searchCount bool) *PageRequest
func (*PageRequest) Offset ¶
func (p *PageRequest) Offset() int
func (*PageRequest) Page ¶
func (p *PageRequest) Page() int
func (*PageRequest) PageSize ¶
func (p *PageRequest) PageSize() int
func (*PageRequest) SearchCount ¶
func (p *PageRequest) SearchCount() bool
func (*PageRequest) SetPage ¶
func (p *PageRequest) SetPage(page int)
func (*PageRequest) SetPageSize ¶
func (p *PageRequest) SetPageSize(pageSize int)
func (*PageRequest) SetSearchCount ¶
func (p *PageRequest) SetSearchCount(searchCount bool)
func (PageRequest) String ¶
func (p PageRequest) String() string
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) FilterGroup ¶
func (q *Query) FilterGroup() *FilterGroup
func (*Query) SubjectModifier ¶
func (q *Query) SubjectModifier() *SubjectModifier
func (*Query) SubjectModifierArgs ¶
func (q *Query) SubjectModifierArgs() map[SubjectModifierArg]any
type RDBTranslator ¶
type RDBTranslator struct {
// contains filtered or unexported fields
}
func NewRDBTranslator ¶
func NewRDBTranslator(engin engine.Engine) *RDBTranslator
func (*RDBTranslator) TranslateCount ¶
func (*RDBTranslator) TranslateDelete ¶
func (*RDBTranslator) TranslateExists ¶
func (*RDBTranslator) TranslateFilter ¶
func (*RDBTranslator) TranslateFilterGroup ¶
func (t *RDBTranslator) TranslateFilterGroup(ctx context.Context, fg *FilterGroup) (result string, err error)
func (*RDBTranslator) TranslateFind ¶
func (*RDBTranslator) TranslateLogicOperator ¶
func (t *RDBTranslator) TranslateLogicOperator(ctx context.Context, operator LogicOperator) (result string, err error)
func (*RDBTranslator) TranslatePager ¶
func (*RDBTranslator) TranslateSort ¶
func (*RDBTranslator) TranslateSorts ¶
func (*RDBTranslator) TranslateTable ¶
type SubjectModifier ¶
type SubjectModifier struct {
// contains filtered or unexported fields
}
func (*SubjectModifier) Keywords ¶
func (s *SubjectModifier) Keywords() []string
func (SubjectModifier) String ¶
func (s SubjectModifier) String() string
func (*SubjectModifier) Subjects ¶
func (s *SubjectModifier) Subjects() map[*Subject]bool
type SubjectModifierArg ¶
type SubjectModifierArg string
type TableOption ¶
type TableOption func(table *simpleTable)
func WithTableSchema ¶
func WithTableSchema(schema string) TableOption
type Translator ¶
type Translator interface { Translate(ctx context.Context, query *Query) (string, error) TranslateFind(ctx context.Context, query *Query) (string, error) TranslateCount(ctx context.Context, query *Query) (string, error) TranslateExists(ctx context.Context, query *Query) (string, error) TranslateDelete(ctx context.Context, query *Query) (string, error) TranslateTable(ctx context.Context, table Table) (string, error) TranslateFilterGroup(ctx context.Context, group *FilterGroup) (string, error) TranslateFilter(ctx context.Context, filter *Filter) (string, error) TranslateLogicOperator(ctx context.Context, operator LogicOperator) (string, error) TranslateSorts(ctx context.Context, sorts []*Sort) (string, error) TranslateSort(ctx context.Context, sort *Sort) (string, error) TranslatePager(ctx context.Context, pager Pager) (string, error) }
Click to show internal directories.
Click to hide internal directories.