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
- func WithFilter(filter *string, repoToFilterMap FilterToRepoMap) Option
- func WithOrder(orderby *string, orderMap OrderToRepoMap) Option
- func WithOrderJoins(fields ...OrderJoinField) Option
- func WithPagination(skip *int, top *int, count *bool) Option
- func WithSearch(search *string, fields ...repo.QueryField) Option
- func WithSearchJoins(fields ...SearchJoinField) Option
- type Order
- type OrderJoinField
- type OrderToRepoItem
- type OrderToRepoMap
- 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" )
View Source
const MaxOrderClauses = 10
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") ErrOrderNotToSpec = errors.New("odata orderby parameter: not to odata spec") ErrOrderInvalidDirection = errors.New("odata orderby parameter: direction not supported") ErrOrderNonSchema = errors.New("odata orderby 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 WithOrder ¶ added in v0.12.2
func WithOrder(orderby *string, orderMap OrderToRepoMap) Option
func WithOrderJoins ¶ added in v0.12.2
func WithOrderJoins(fields ...OrderJoinField) 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 Order ¶ added in v0.12.2
type Order struct {
// contains filtered or unexported fields
}
func NewOrder ¶ added in v0.12.2
func NewOrder(orderby *string, m OrderToRepoMap, joinFields []OrderJoinField) (*Order, error)
type OrderJoinField ¶ added in v0.12.2
type OrderJoinField struct {
UserField string
Column string
Join repo.JoinCondition
}
type OrderToRepoItem ¶ added in v0.12.2
type OrderToRepoItem struct {
DBName repo.QueryField
}
OrderToRepoItem maps a user-facing field to a DB column. Only mapped fields reach the repo, which puts the field into ORDER BY unquoted, so the map is the guard against injection.
type OrderToRepoMap ¶ added in v0.12.2
type OrderToRepoMap map[string]OrderToRepoItem
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.