Documentation ¶
Index ¶
- func MatchIfDate(dateValueStr string, filterValueStr string, filter FilterOption) (match bool, err error)
- func MatchesFilters(v interface{}, filterOptions []FilterOption) (bool, error)
- func RequestedFields(fields []FieldsOption, resource string) map[string]bool
- func SortFiltersByOperator(a []FilterOption)
- func SplitFilters(options []FilterOption, keys map[string]bool) ([]FilterOption, []FilterOption)
- func ValidateFieldsOptions(fieldOptions []FieldsOption, supportedFields map[string]map[string]bool) errors2.APIErrors
- func ValidateFilterOptions(fo []FilterOption, supportedFields map[string]bool) errors2.APIErrors
- func ValidateListOptions(lo *ListOptions, supportedSorts map[string]bool, ...) error
- func ValidatePagination(pagination *Pagination, config *PaginationConfig) errors2.APIErrors
- func ValidateRetrieveOptions(lo *RetrieveOptions, supportedFields map[string]map[string]bool) error
- func ValidateSortOptions(so []SortOption, supportedFields map[string]bool) errors2.APIErrors
- type FieldsOption
- type FilterLogicalOperator
- type FilterOperatorType
- type FilterOption
- type ListOptions
- type Pagination
- type PaginationConfig
- type RequestInfo
- type RetrieveOptions
- type SQLConverter
- func (c *SQLConverter) AddOrderBy(sortOptions []SortOption, q string) string
- func (c *SQLConverter) AddWhere(filterOptions []FilterOption, q string, params []interface{}) (string, []interface{})
- func (c *SQLConverter) AppendOptionsToQuery(o *ListOptions, q string, params []interface{}) (string, []interface{})
- func (c *SQLConverter) ConvertListOptionsToQuery(lo *ListOptions, q string) (qOut string, params []interface{})
- func (c *SQLConverter) ConvertRetrieveOptionsToQuery(ro *RetrieveOptions, q string) string
- func (c *SQLConverter) ReplaceStarSelect(fieldOptions []FieldsOption, q string) string
- type SortOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchIfDate ¶
func MatchIfDate(dateValueStr string, filterValueStr string, filter FilterOption) (match bool, err error)
func MatchesFilters ¶
func MatchesFilters(v interface{}, filterOptions []FilterOption) (bool, error)
func RequestedFields ¶
func RequestedFields(fields []FieldsOption, resource string) map[string]bool
func SortFiltersByOperator ¶
func SortFiltersByOperator(a []FilterOption)
func SplitFilters ¶
func SplitFilters(options []FilterOption, keys map[string]bool) ([]FilterOption, []FilterOption)
func ValidateFieldsOptions ¶
func ValidateFilterOptions ¶
func ValidateFilterOptions(fo []FilterOption, supportedFields map[string]bool) errors2.APIErrors
func ValidateListOptions ¶
func ValidateListOptions(lo *ListOptions, supportedSorts map[string]bool, supportedFilters map[string]bool, supportedFields map[string]map[string]bool, paginationConfig *PaginationConfig) error
ValidateListOptions when supportedFields is nil, the fields options are disabled and will not be validated or used, same for pagination
func ValidatePagination ¶
func ValidatePagination(pagination *Pagination, config *PaginationConfig) errors2.APIErrors
func ValidateRetrieveOptions ¶
func ValidateRetrieveOptions(lo *RetrieveOptions, supportedFields map[string]map[string]bool) error
func ValidateSortOptions ¶
func ValidateSortOptions(so []SortOption, supportedFields map[string]bool) errors2.APIErrors
Types ¶
type FieldsOption ¶
func ParseFieldsOptions ¶
func ParseFieldsOptions(values url.Values) []FieldsOption
type FilterLogicalOperator ¶
type FilterLogicalOperator string
const ( FilterLogicalOperatorTypeOR FilterLogicalOperator = "or" FilterLogicalOperatorTypeAND FilterLogicalOperator = "and" )
type FilterOperatorType ¶
type FilterOperatorType string
const ( FilterOperatorTypeEQ FilterOperatorType = "eq" FilterOperatorTypeGT FilterOperatorType = "gt" FilterOperatorTypeLT FilterOperatorType = "lt" FilterOperatorTypeSince FilterOperatorType = "since" FilterOperatorTypeUntil FilterOperatorType = "until" )
func (FilterOperatorType) Code ¶
func (fot FilterOperatorType) Code() string
type FilterOption ¶
type FilterOption struct { Column []string Operator FilterOperatorType Values []string // Values are [ValuesLogicalOperator]ed together (only AND, OR, default OR) ValuesLogicalOperator FilterLogicalOperator }
func ParseFilterOptions ¶
func ParseFilterOptions(values url.Values) []FilterOption
func (FilterOption) String ¶
func (fo FilterOption) String() string
type ListOptions ¶
type ListOptions struct { Sorts []SortOption Filters []FilterOption Fields []FieldsOption Pagination *Pagination }
func GetListOptions ¶
func GetListOptions(req *http.Request) *ListOptions
type Pagination ¶
func NewPagination ¶
func NewPagination(limit, offset int) *Pagination
func ParsePagination ¶
func ParsePagination(values url.Values) *Pagination
func (Pagination) GetStartEnd ¶
func (p Pagination) GetStartEnd(totalCount int) (int, int)
type PaginationConfig ¶
type RequestInfo ¶
type RequestInfo struct {
URL string
}
func ParseRequestInfo ¶
func ParseRequestInfo(req *http.Request) *RequestInfo
type RetrieveOptions ¶
type RetrieveOptions struct {
Fields []FieldsOption
}
func GetRetrieveOptions ¶
func GetRetrieveOptions(req *http.Request) *RetrieveOptions
type SQLConverter ¶
type SQLConverter struct {
// contains filtered or unexported fields
}
func NewSQLConverter ¶
func NewSQLConverter(dbDriverName string) *SQLConverter
NewSQLConverter converts query parameters into SQL language
func (*SQLConverter) AddOrderBy ¶
func (c *SQLConverter) AddOrderBy(sortOptions []SortOption, q string) string
func (*SQLConverter) AddWhere ¶
func (c *SQLConverter) AddWhere(filterOptions []FilterOption, q string, params []interface{}) (string, []interface{})
func (*SQLConverter) AppendOptionsToQuery ¶
func (c *SQLConverter) AppendOptionsToQuery(o *ListOptions, q string, params []interface{}) (string, []interface{})
func (*SQLConverter) ConvertListOptionsToQuery ¶
func (c *SQLConverter) ConvertListOptionsToQuery(lo *ListOptions, q string) (qOut string, params []interface{})
func (*SQLConverter) ConvertRetrieveOptionsToQuery ¶
func (c *SQLConverter) ConvertRetrieveOptionsToQuery(ro *RetrieveOptions, q string) string
func (*SQLConverter) ReplaceStarSelect ¶
func (c *SQLConverter) ReplaceStarSelect(fieldOptions []FieldsOption, q string) string
type SortOption ¶
func ParseSortOptions ¶
func ParseSortOptions(values url.Values) []SortOption
Click to show internal directories.
Click to hide internal directories.