filters

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REQUES_PARAM_SORT_KEY  = "sort"
	SEPARATOR_METHOD_VALUE = "_"

	ASC  SortKey = "asc"
	DESC SortKey = "desc"

	GT   FilteringMethod = "gt"
	GTE  FilteringMethod = "gte"
	LT   FilteringMethod = "lt"
	LTE  FilteringMethod = "lte"
	EQ   FilteringMethod = "eq"
	IN   FilteringMethod = "in"
	LIKE FilteringMethod = "like"
)

Variables

View Source
var (
	FilterAssociations map[FilteringMethod]string = map[FilteringMethod]string{
		GT:   ">",
		GTE:  ">=",
		LT:   "<",
		LTE:  "<=",
		EQ:   "=",
		IN:   "IN",
		LIKE: "LIKE",
	}
)

Functions

func ConvertFromLikeSearch

func ConvertFromLikeSearch(word string) string

func CreateManyORParams

func CreateManyORParams(params []sql.NamedArg, where string, query *gorm.DB) *gorm.DB

func FilterWay

func FilterWay(filterWay string) func(string, string) (string, string)

Types

type FilterAndSortBackend

type FilterAndSortBackend struct {
	FilterParams []FilterOption
	SortParams   SortOption
}

func (*FilterAndSortBackend) Filter

func (f *FilterAndSortBackend) Filter(query *gorm.DB) *gorm.DB

func (*FilterAndSortBackend) Sort

func (f *FilterAndSortBackend) Sort(query *gorm.DB) *gorm.DB

type FilterAndSortInterface

type FilterAndSortInterface interface {
	Filter(*gorm.DB) *gorm.DB
	Sort(*gorm.DB) *gorm.DB
}

type FilterFunc

type FilterFunc func(*gorm.DB, string, string) *gorm.DB

func WhereFilter

func WhereFilter(param string) FilterFunc

type FilterOption

type FilterOption struct {
	Field           string
	Value           interface{}
	CollName        string
	FilteringMethod FilteringMethod
	FilterFunc      func(*gorm.DB, interface{}) *gorm.DB
	TypeQueryParam  TypeQueryParam
}

func (*FilterOption) ValidateQueryParams

func (f *FilterOption) ValidateQueryParams(value string) bool

type FilterParameter

type FilterParameter struct {
	Value       string
	Modificator string
	Param       string
}

type FilterQuerySet

type FilterQuerySet struct {
	ParamName  string
	FieldName  string
	QueryParam QueryParam
	FilterFunc func(*gorm.DB, interface{}) *gorm.DB
}

type FilterViewInterface

type FilterViewInterface interface {
	GetFilteredFields() []FilterQuerySet
	GetSortAllowFields() []FilterQuerySet
}

type FilteringMethod

type FilteringMethod string

type Parameters

type Parameters struct {
	FilterOption []FilterOption
	SortOption   SortOption
}

func FilterFromRequest

func FilterFromRequest(r *http.Request, filterFields []FilterQuerySet, sortAllowFields []FilterQuerySet) Parameters

type QueryParam

type QueryParam struct {
	TypeQueryParam TypeQueryParam `json:"typeQueryParam"`
	Enum           []string       `json:"enum"`
	Directory      string         `json:"directory"`
}

type SortKey

type SortKey string

type SortOption

type SortOption struct {
	Field    string
	CollName string
	SortKey  SortKey
}

type TypeQueryParam

type TypeQueryParam string
const (
	Number  TypeQueryParam = "number"
	Boolean TypeQueryParam = "bool"
	String  TypeQueryParam = "string"
	Date    TypeQueryParam = "date"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL