filter

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 8 Imported by: 252

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Eq  = CompareOperator("=")
	Neq = CompareOperator("!=")
	Gt  = CompareOperator(">")
	Gte = CompareOperator(">=")
	Lt  = CompareOperator("<")
	Lte = CompareOperator("<=")

	OR  = CompositeOperator("OR")
	AND = CompositeOperator("AND")
)

Functions

func CompareSatisfies

func CompareSatisfies(refop, op CompareOperator, cmp int) (res bool)

Types

type AndCondition

type AndCondition struct {
	Or []Condition `@@ { [("AND" | "+" )] @@ }`
}

type Array

type Array []Value

type Boolean

type Boolean bool

func (*Boolean) Capture

func (b *Boolean) Capture(values []string) error

type Compare

type Compare struct {
	Operator CompareOperator `@CompareOperator`
	Value    Value           `@@`
}

type CompareOperator

type CompareOperator string

func (*CompareOperator) Capture

func (op *CompareOperator) Capture(values []string) error

func (*CompareOperator) MatchCompareResult

func (op *CompareOperator) MatchCompareResult(cmp int) bool

type CompositeOperator

type CompositeOperator string

type Condition

type Condition struct {
	Not           *Condition        `  "NOT" @@`
	SubExpression *Expression       `| "(" @@ ")"`
	Operand       *ConditionOperand `|  @@`
}

type ConditionOperand

type ConditionOperand struct {
	FieldPath    string       `@FieldPath`
	ConditionRHS ConditionRHS `@@ `
}

type ConditionRHS

type ConditionRHS struct {
	Compare  *Compare  `  @@`
	Is       *Is       `| "IS" @@`
	In       Array     `| "IN" ("(" @@ { "," @@ } ")" | "[" @@ { "," @@ } "]")`
	NotIn    Array     `| "NOT" "IN" ("(" @@ { "," @@ } ")" | "[" @@ { "," @@ } "]")`
	Contains *Contains `| ("CONTAINS" | "HAS") @@`
	Like     *string   `| "LIKE" @String`
}

func (ConditionRHS) JSONValue

func (crhs ConditionRHS) JSONValue() ([]byte, error)

type Contains

type Contains struct {
	Any   Array  `  "ANY" ("(" @@ { "," @@ } ")" | "[" @@ { "," @@ } "]")`
	All   Array  `| "ALL" ("(" @@ { "," @@ } ")" | "[" @@ { "," @@ } "]")`
	Value *Value `| ["VALUE"] @@`
}

func (*Contains) GetArray

func (c *Contains) GetArray() Array

type Expression

type Expression struct {
	And []AndCondition `@@ { ("OR" | "|") @@ }`
}

func Parse

func Parse(data []byte) (*Expression, error)

type FilterCondOptions

type FilterCondOptions interface {
	IsNot() bool
}

func MakeFilterCondOptions

func MakeFilterCondOptions(opts []FilterConditionOption) FilterCondOptions

type FilterConditionOption

type FilterConditionOption func(*condOptionsCfg)

func Not

type Is

type Is struct {
	Not  bool `[ @"NOT" ]`
	Null bool `(  @"NULL"`
	NaN  bool ` | @"NAN" )`
}

type Map added in v0.4.39

type Map struct {
	Entries []*MapEntry `"{" ( @@ ( ( "," )? @@ )* )? "}"`
}

type MapEntry added in v0.4.39

type MapEntry struct {
	Key   *Value `@@`
	Value *Value `":"? @@`
}

type Value

type Value struct {
	Null    bool     `(  @"NULL"`
	Boolean *Boolean ` | @("TRUE" | "FALSE")`
	Number  *string  ` | @Number`
	String  *string  ` | @String`
	Map     *Map     ` | @@ )`
}

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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