Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AllowedOperators = map[Operator]bool{ OperatorEQ: true, OperatorNE: true, OperatorGT: true, OperatorGTE: true, OperatorLT: true, OperatorLTE: true, OperatorLIKE: true, OperatorIN: true, OperatorNOTIN: true, }
AllowedOperators is a map of all allowed operators
Functions ¶
func ApplyFilters ¶
ApplyFilters applies filters to a GORM query
Types ¶
type Config ¶
type Config struct {
// AllowedFields is a map of allowed field names to their types
// If empty, all fields are allowed
AllowedFields map[string]string // "field_name" -> "string", "int", "time", etc.
// FieldMapping maps query parameter names to database column names
// If empty, field names are used as-is
FieldMapping map[string]string
// CustomValidators allows custom validation for specific fields
CustomValidators map[string]func(value string) error
}
Config holds filter configuration
type Operator ¶
type Operator string
Operator represents a filter operator
const ( // OperatorEQ equals OperatorEQ Operator = "eq" // OperatorNE not equals OperatorNE Operator = "ne" // OperatorGT greater than OperatorGT Operator = "gt" // OperatorGTE greater than or equal OperatorGTE Operator = "gte" // OperatorLT less than OperatorLT Operator = "lt" // OperatorLTE less than or equal OperatorLTE Operator = "lte" // OperatorLIKE like (for strings) OperatorLIKE Operator = "like" // OperatorIN in (for arrays) OperatorIN Operator = "in" // OperatorNOTIN not in (for arrays) OperatorNOTIN Operator = "not_in" )
Click to show internal directories.
Click to hide internal directories.