filter

package
v0.0.0-...-292c480 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Field     string
	Operation OperationType
	Value     string
	SkipRule  bool
}

func (Condition) Values

func (f Condition) Values() []string

type Config

type Config struct {
	Rules      []Rule
	Conditions []Condition
}

Config for filter

func (*Config) Apply

func (c *Config) Apply(f *Filter)

Apply applies config to paginator

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Filter

New creates a query filter

func (*Filter) Apply

func (f *Filter) Apply(query *goqu.SelectDataset) (*goqu.SelectDataset, error)

func (*Filter) SetConditions

func (f *Filter) SetConditions(conditions ...Condition)

SetConditions sets filter rules

func (*Filter) SetRules

func (f *Filter) SetRules(rules ...Rule)

SetRules sets paging rules

type OperationType

type OperationType string
const (
	OperationEqual          OperationType = "eq"
	OperationNotEqual       OperationType = "neq"
	OperationLessThan       OperationType = "lt"
	OperationLessOrEqual    OperationType = "lte"
	OperationGreaterThan    OperationType = "gt"
	OperationGreaterOrEqual OperationType = "gte"
	OperationHas            OperationType = "has"
	OperationIn             OperationType = "in"
	OperationIsNull         OperationType = "isnull"
)

type Option

type Option interface {
	Apply(f *Filter)
}

Option for filter

func WithConditions

func WithConditions(filters ...Condition) Option

WithConditions configures filter for query

func WithRules

func WithRules(rules ...Rule) Option

WithRules configures rules for query

type Rule

type Rule struct {
	Key        string
	Operation  []OperationType
	Type       VariableType
	AcceptNull bool
}

type VariableType

type VariableType string
const (
	VariableString          VariableType = "string"
	VariableInteger         VariableType = "number"
	VariableBool            VariableType = "boolean"
	VariableDecimal         VariableType = "decimal"
	VariableDate            VariableType = "date"
	VariableTimestamp       VariableType = "timestamp"
	VariableTimestampMillis VariableType = "timestamp_millis"
)

Jump to

Keyboard shortcuts

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