Documentation
¶
Index ¶
- Constants
- Variables
- func MaxLengthValidator(maxLength int) func(string) bool
- func ToUpper(s string) string
- type Filter
- type FilterItem
- type FilterToRepoItem
- type FilterToRepoMap
- type OData
- type Option
- type RepoValueModifier
- type RepoValueValidator
- type Search
- type SearchItem
- type SearchJoinField
- type Type
Constants ¶
View Source
const ( Eq = "eq" Ne = "ne" Gt = "gt" Ge = "ge" Lt = "lt" Le = "le" String Type = "STRING" Bool Type = "BOOL" Int Type = "INT" UUID Type = "UUID" )
View Source
const ( None = "" And = "and" Or = "or" )
Variables ¶
View Source
var ( ErrFilterNotToSpec = errors.New("odata filter parameter: not to odata spec") ErrFilterOperationNotSupported = errors.New("odata filter parameter: operation not supported") ErrFilterInvalidValue = errors.New("odata filter parameter: value invalid") ErrFilterTypeNotSupported = errors.New("odata filter parameter: type not supported") ErrFilterValueConversionFailed = errors.New("odata filter parameter: type conversion failed") ErrFilterNonSchema = errors.New("odata filter parameter: invalid db mapping") )
Functions ¶
func MaxLengthValidator ¶
Types ¶
type Filter ¶
type Filter struct {
Items []FilterItem
FilterToRepoMap FilterToRepoMap
}
func NewFilter ¶
func NewFilter(filter *string, filterToRepoMap FilterToRepoMap) (*Filter, error)
NewFilter does not support nested OData operations () If needed in the future the data structure needs to be swap from a slice to a tree As this is not a simple implementation it was skipped for now
func (*Filter) GetFieldValues ¶ added in v0.10.0
func (f *Filter) GetFieldValues(field repo.QueryField) ([]any, error)
type FilterItem ¶ added in v0.10.0
type FilterToRepoItem ¶ added in v0.10.0
type FilterToRepoItem struct {
Type Type
DBName repo.QueryField // used whenever there is a direct mapping to the DB
DBQuery func(query *repo.Query, value any) *repo.Query // used whenever odata maps to a query
ValueModifier RepoValueModifier
ValueValidator RepoValueValidator
}
type FilterToRepoMap ¶ added in v0.10.0
type FilterToRepoMap map[string]FilterToRepoItem
type OData ¶ added in v0.10.0
type OData struct {
// contains filtered or unexported fields
}
func (*OData) GetPagination ¶ added in v0.10.0
func (o *OData) GetPagination() repo.Pagination
type Option ¶ added in v0.10.0
type Option func(*OData)
func WithFilter ¶ added in v0.10.0
func WithFilter(filter *string, repoToFilterMap FilterToRepoMap) Option
func WithSearch ¶ added in v0.10.0
func WithSearch(search *string, fields ...repo.QueryField) Option
func WithSearchJoins ¶ added in v0.10.0
func WithSearchJoins(fields ...SearchJoinField) Option
type RepoValueModifier ¶ added in v0.10.0
type RepoValueValidator ¶ added in v0.10.0
type Search ¶ added in v0.10.0
type Search struct {
Items []SearchItem
Fields []repo.QueryField
JoinFields []SearchJoinField
}
func NewSearch ¶ added in v0.10.0
func NewSearch(search *string, fields []repo.QueryField, joinFields []SearchJoinField) (*Search, error)
NewSearch does not support nested OData operations () This currently does not support nested operations () If needed in the future the data structure needs to be swap from a slice to a tree As this is not a simple implementation it was skipped for now
type SearchItem ¶ added in v0.10.0
type SearchJoinField ¶ added in v0.10.0
type SearchJoinField struct {
Column string
Join repo.JoinCondition
}
Click to show internal directories.
Click to hide internal directories.