Documentation ¶
Index ¶
- Constants
- func Operator(value string) string
- func OperatorOk(value string) (string, bool)
- type AndExpression
- func (e AndExpression) And(exp Expression) Expression
- func (e AndExpression) AndEqual(name string, value any) Expression
- func (e AndExpression) AndGreaterOrEqual(name string, value any) Expression
- func (e AndExpression) AndGreaterThan(name string, value any) Expression
- func (e AndExpression) AndIn(name string, value any) Expression
- func (e AndExpression) AndLessOrEqual(name string, value any) Expression
- func (e AndExpression) AndLessThan(name string, value any) Expression
- func (e AndExpression) AndNotEqual(name string, value any) Expression
- func (e AndExpression) AndNotIn(name string, value any) Expression
- func (e AndExpression) IsEmpty() bool
- func (e AndExpression) Match(fn MatcherFunc) bool
- func (e AndExpression) NotEmpty() bool
- func (e AndExpression) Or(exp Expression) Expression
- type EmptyExpression
- func (e EmptyExpression) And(exp Expression) Expression
- func (e EmptyExpression) AndEqual(name string, value any) Expression
- func (e EmptyExpression) AndGreaterOrEqual(name string, value any) Expression
- func (e EmptyExpression) AndGreaterThan(name string, value any) Expression
- func (e EmptyExpression) AndIn(name string, value any) Expression
- func (e EmptyExpression) AndLessOrEqual(name string, value any) Expression
- func (e EmptyExpression) AndLessThan(name string, value any) Expression
- func (e EmptyExpression) AndNotEqual(name string, value any) Expression
- func (e EmptyExpression) AndNotIn(name string, value any) Expression
- func (e EmptyExpression) IsEmpty() bool
- func (e EmptyExpression) Match(fn MatcherFunc) bool
- func (e EmptyExpression) NotEmpty() bool
- func (e EmptyExpression) Or(exp Expression) Expression
- type Expression
- type MatcherFunc
- type OrExpression
- func (e OrExpression) And(exp Expression) Expression
- func (e OrExpression) AndEqual(name string, value any) Expression
- func (e OrExpression) AndGreaterOrEqual(name string, value any) Expression
- func (e OrExpression) AndGreaterThan(name string, value any) Expression
- func (e OrExpression) AndIn(name string, value any) Expression
- func (e OrExpression) AndLessOrEqual(name string, value any) Expression
- func (e OrExpression) AndLessThan(name string, value any) Expression
- func (e OrExpression) AndNotEqual(name string, value any) Expression
- func (e OrExpression) AndNotIn(name string, value any) Expression
- func (e OrExpression) IsEmpty() bool
- func (e OrExpression) Match(fn MatcherFunc) bool
- func (e OrExpression) NotEmpty() bool
- func (e OrExpression) Or(exp Expression) Expression
- type Predicate
- func BeginsWith(field string, value any) Predicate
- func ContainedBy(field string, value any) Predicate
- func Contains(field string, value any) Predicate
- func EndsWith(field string, value any) Predicate
- func Equal(field string, value any) Predicate
- func GreaterOrEqual(field string, value any) Predicate
- func GreaterThan(field string, value any) Predicate
- func In(field string, value any) Predicate
- func LessOrEqual(field string, value any) Predicate
- func LessThan(field string, value any) Predicate
- func New(field string, operator string, value any) Predicate
- func NotEqual(field string, value any) Predicate
- func (predicate Predicate) And(exp Expression) Expression
- func (predicate Predicate) AndEqual(name string, value any) Expression
- func (predicate Predicate) AndGreaterOrEqual(name string, value any) Expression
- func (predicate Predicate) AndGreaterThan(name string, value any) Expression
- func (predicate Predicate) AndIn(name string, value any) Expression
- func (predicate Predicate) AndLessOrEqual(name string, value any) Expression
- func (predicate Predicate) AndLessThan(name string, value any) Expression
- func (predicate Predicate) AndNotEqual(name string, value any) Expression
- func (predicate Predicate) AndNotIn(name string, value any) Expression
- func (predicate Predicate) IsEmpty() bool
- func (predicate Predicate) Match(fn MatcherFunc) bool
- func (predicate Predicate) NotEmpty() bool
- func (predicate Predicate) Or(exp Expression) Expression
- func (predicate Predicate) OrEqual(name string, value any) Expression
- func (predicate Predicate) OrGreaterOrEqual(name string, value any) Expression
- func (predicate Predicate) OrGreaterThan(name string, value any) Expression
- func (predicate Predicate) OrIn(name string, value any) Expression
- func (predicate Predicate) OrLessOrEqual(name string, value any) Expression
- func (predicate Predicate) OrLessThan(name string, value any) Expression
- func (predicate Predicate) OrNotEqual(name string, value any) Expression
- func (predicate Predicate) OrNotIn(name string, value any) Expression
Constants ¶
const OperatorBeginsWith = "BEGINS"
OperatorBeginsWith represents a "begins with" comparison, when used in Predicates and Criteria. It is only valid for string values.
const OperatorContainedBy = "CONTAINED BY"
OperatorContainedBy represents a "contained by" comparison, when used in Predicates and Criteria. It is only valid for string values.
const OperatorContains = "CONTAINS"
OperatorContains represents a "contains" comparison, when used in Predicates and Criteria. It is only valid for string values.
const OperatorEndsWith = "ENDS"
OperatorEndsWith represents a "ends with" comparison, when used in Predicates and Criteria. It is only valid for string values.
const OperatorEqual = "="
OperatorEqual represents an "equals" comparison, when used in Predicates and Criteria
const OperatorGreaterOrEqual = ">="
OperatorGreaterOrEqual represents an "greater or equal" comparison, when used in Predicates and Criteria
const OperatorGreaterThan = ">"
OperatorGreaterThan represents an "greater than" comparison, when used in Predicates and Criteria
const OperatorIn = "IN"
OperatorIn represents a "in" comparison, when used in Predicates and Criteria.
const OperatorLessOrEqual = "<="
OperatorLessOrEqual represents an "less or equal" comparison, when used in Predicates and Criteria
const OperatorLessThan = "<"
OperatorLessThan represents a "less than" comparison, when used in Predicates and Criteria
const OperatorNotEqual = "!="
OperatorNotEqual represents a "not equals" comparison, when used in Predicates and Criteria
const OperatorNotIn = "NOT IN"
OperatorNotIn represents a "not in" comparison, when used in Predicates and Criteria.
Variables ¶
This section is empty.
Functions ¶
func OperatorOk ¶ added in v0.8.1
OperatorOk tries to convert non-standard values into standard operators. If a match is found, then it returns the standardized value and TRUE. If a match is not found, then the default EQUAL is returned along with a FALSE.
Types ¶
type AndExpression ¶
type AndExpression []Expression
AndExpression combines a series of sub-expressions using AND logic
func And ¶
func And(expressions ...Expression) AndExpression
And combines one or more expression parameters into an AndExpression
func (AndExpression) And ¶
func (e AndExpression) And(exp Expression) Expression
func (AndExpression) AndEqual ¶
func (e AndExpression) AndEqual(name string, value any) Expression
func (AndExpression) AndGreaterOrEqual ¶
func (e AndExpression) AndGreaterOrEqual(name string, value any) Expression
func (AndExpression) AndGreaterThan ¶
func (e AndExpression) AndGreaterThan(name string, value any) Expression
func (AndExpression) AndIn ¶ added in v0.1.2
func (e AndExpression) AndIn(name string, value any) Expression
func (AndExpression) AndLessOrEqual ¶
func (e AndExpression) AndLessOrEqual(name string, value any) Expression
func (AndExpression) AndLessThan ¶
func (e AndExpression) AndLessThan(name string, value any) Expression
func (AndExpression) AndNotEqual ¶
func (e AndExpression) AndNotEqual(name string, value any) Expression
func (AndExpression) AndNotIn ¶ added in v0.1.2
func (e AndExpression) AndNotIn(name string, value any) Expression
func (AndExpression) IsEmpty ¶ added in v0.8.0
func (e AndExpression) IsEmpty() bool
func (AndExpression) Match ¶
func (e AndExpression) Match(fn MatcherFunc) bool
Match implements the Expression interface. It loops through all sub-expressions and returns TRUE if all of them match
func (AndExpression) NotEmpty ¶ added in v0.8.0
func (e AndExpression) NotEmpty() bool
func (AndExpression) Or ¶ added in v0.1.0
func (e AndExpression) Or(exp Expression) Expression
type EmptyExpression ¶ added in v0.1.0
type EmptyExpression struct{}
func (EmptyExpression) And ¶ added in v0.1.0
func (e EmptyExpression) And(exp Expression) Expression
func (EmptyExpression) AndEqual ¶ added in v0.1.2
func (e EmptyExpression) AndEqual(name string, value any) Expression
func (EmptyExpression) AndGreaterOrEqual ¶ added in v0.1.2
func (e EmptyExpression) AndGreaterOrEqual(name string, value any) Expression
func (EmptyExpression) AndGreaterThan ¶ added in v0.1.2
func (e EmptyExpression) AndGreaterThan(name string, value any) Expression
func (EmptyExpression) AndIn ¶ added in v0.1.2
func (e EmptyExpression) AndIn(name string, value any) Expression
func (EmptyExpression) AndLessOrEqual ¶ added in v0.1.2
func (e EmptyExpression) AndLessOrEqual(name string, value any) Expression
func (EmptyExpression) AndLessThan ¶ added in v0.1.2
func (e EmptyExpression) AndLessThan(name string, value any) Expression
func (EmptyExpression) AndNotEqual ¶ added in v0.1.2
func (e EmptyExpression) AndNotEqual(name string, value any) Expression
func (EmptyExpression) AndNotIn ¶ added in v0.1.2
func (e EmptyExpression) AndNotIn(name string, value any) Expression
func (EmptyExpression) IsEmpty ¶ added in v0.8.0
func (e EmptyExpression) IsEmpty() bool
func (EmptyExpression) Match ¶ added in v0.1.0
func (e EmptyExpression) Match(fn MatcherFunc) bool
func (EmptyExpression) NotEmpty ¶ added in v0.8.0
func (e EmptyExpression) NotEmpty() bool
func (EmptyExpression) Or ¶ added in v0.1.0
func (e EmptyExpression) Or(exp Expression) Expression
type Expression ¶
type Expression interface { // And returns a new expression that combines this expression with another as an AndExpression And(Expression) Expression // Or returns a new expression that combines this expression with another as an OrExpression Or(Expression) Expression Match(MatcherFunc) bool // AndEqual is a shortcut that creates a new AndExpression using the Equal comparison AndEqual(name string, value any) Expression // AndNotEqual is a shortcut that creates a new AndExpression using the NotEqual comparison AndNotEqual(name string, value any) Expression // AndLessThan is a shortcut that creates a new AndExpression using the LessThan comparison AndLessThan(name string, value any) Expression // AndLessOrEqual is a shortcut that creates a new AndExpression using the LessOrEqual comparison AndLessOrEqual(name string, value any) Expression // AndGreaterThan is a shortcut that creates a new AndExpression using the GreaterThan comparison AndGreaterThan(name string, value any) Expression // AndGreaterOrEqual is a shortcut that creates a new AndExpression using the GreaterOrEqual comparison AndGreaterOrEqual(name string, value any) Expression // AndIn is a shortcut that creates a new AndExpression using the In comparison AndIn(name string, value any) Expression // AndNotIn is a shortcut that creates a new AndExpression using the NotIn comparison AndNotIn(name string, value any) Expression // IsEmpty returns TRUE if an expression does not have any predicates IsEmpty() bool // NotEmpty returns TRUE if an expression has one or more predicates NotEmpty() bool }
Expression is an interface that is implemented by Predicates, AndExpressions, and OrExpressions. It enables any of these items to be embedded into the criteria of a data.Query
func All ¶
func All() Expression
All a syntactic sugar alias for And(), so that expressions that query all values in a dataset read nicely.
func Empty ¶ added in v0.1.0
func Empty() Expression
func Parse ¶ added in v0.7.0
func Parse(value string) Expression
Parse converts a string into an Expression
type MatcherFunc ¶
MatcherFunc is a function signature that is passed in to the .Match() functions of every Expression. It allows the caller to handle the actual matching independently of their underlying data, while the Expression objects handle the program flow.
type OrExpression ¶
type OrExpression []Expression
OrExpression compares a series of sub-expressions, using the OR logic
func Or ¶
func Or(expressions ...Expression) OrExpression
Or combines one or more expression parameters into an OrExpression
func (OrExpression) And ¶ added in v0.1.0
func (e OrExpression) And(exp Expression) Expression
And returns a fully populated AndExpression
func (OrExpression) AndEqual ¶ added in v0.1.2
func (e OrExpression) AndEqual(name string, value any) Expression
func (OrExpression) AndGreaterOrEqual ¶ added in v0.1.2
func (e OrExpression) AndGreaterOrEqual(name string, value any) Expression
func (OrExpression) AndGreaterThan ¶ added in v0.1.2
func (e OrExpression) AndGreaterThan(name string, value any) Expression
func (OrExpression) AndIn ¶ added in v0.1.2
func (e OrExpression) AndIn(name string, value any) Expression
func (OrExpression) AndLessOrEqual ¶ added in v0.1.2
func (e OrExpression) AndLessOrEqual(name string, value any) Expression
func (OrExpression) AndLessThan ¶ added in v0.1.2
func (e OrExpression) AndLessThan(name string, value any) Expression
func (OrExpression) AndNotEqual ¶ added in v0.1.2
func (e OrExpression) AndNotEqual(name string, value any) Expression
func (OrExpression) AndNotIn ¶ added in v0.1.2
func (e OrExpression) AndNotIn(name string, value any) Expression
func (OrExpression) IsEmpty ¶ added in v0.8.0
func (e OrExpression) IsEmpty() bool
func (OrExpression) Match ¶
func (e OrExpression) Match(fn MatcherFunc) bool
Match implements the Expression interface. It loops through all sub-expressions and returns TRUE if any of them match
func (OrExpression) NotEmpty ¶ added in v0.8.0
func (e OrExpression) NotEmpty() bool
func (OrExpression) Or ¶
func (e OrExpression) Or(exp Expression) Expression
Or appends a new expression into this compound expression
type Predicate ¶
Predicate represents a single true/false comparison
func BeginsWith ¶
BeginsWith creates a new Predicate using an "BeginsWith" comparison
func ContainedBy ¶ added in v0.1.0
ContainedBy creates a new Predicate using an "ContainedBy" comparison
func GreaterOrEqual ¶
GreaterOrEqual creates a new Predicate using an "Greater Or Equal" comparison
func GreaterThan ¶
GreaterThan creates a new Predicate using an "Greater Than" comparison
func LessOrEqual ¶
LessOrEqual creates a new Predicate using an "Less Or Equal" comparison
func (Predicate) And ¶
func (predicate Predicate) And(exp Expression) Expression
And combines this predicate with another pre-existing expression into a new And expression
func (Predicate) AndEqual ¶
func (predicate Predicate) AndEqual(name string, value any) Expression
AndEqual combines this predicate with another one (created from the arguments) into an AndExpression
func (Predicate) AndGreaterOrEqual ¶
func (predicate Predicate) AndGreaterOrEqual(name string, value any) Expression
AndGreaterOrEqual combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) AndGreaterThan ¶
func (predicate Predicate) AndGreaterThan(name string, value any) Expression
AndGreaterThan combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) AndIn ¶ added in v0.1.2
func (predicate Predicate) AndIn(name string, value any) Expression
AndIn combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) AndLessOrEqual ¶
func (predicate Predicate) AndLessOrEqual(name string, value any) Expression
AndLessOrEqual combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) AndLessThan ¶
func (predicate Predicate) AndLessThan(name string, value any) Expression
AndLessThan combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) AndNotEqual ¶
func (predicate Predicate) AndNotEqual(name string, value any) Expression
AndNotEqual combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) AndNotIn ¶ added in v0.1.2
func (predicate Predicate) AndNotIn(name string, value any) Expression
AndNotIn combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) Match ¶
func (predicate Predicate) Match(fn MatcherFunc) bool
Match implements the Expression interface. It uses a MatcherFunc to determine if this predicate matches an arbitrary dataset.
func (Predicate) Or ¶
func (predicate Predicate) Or(exp Expression) Expression
Or combines this predicate with another pre-existing expression into a new Or expression
func (Predicate) OrEqual ¶ added in v0.6.0
func (predicate Predicate) OrEqual(name string, value any) Expression
OrEqual combines this predicate with another one (created from the arguments) into an OrExpression
func (Predicate) OrGreaterOrEqual ¶ added in v0.6.0
func (predicate Predicate) OrGreaterOrEqual(name string, value any) Expression
OrGreaterOrEqual combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) OrGreaterThan ¶ added in v0.6.0
func (predicate Predicate) OrGreaterThan(name string, value any) Expression
OrGreaterThan combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) OrIn ¶ added in v0.6.0
func (predicate Predicate) OrIn(name string, value any) Expression
OrIn combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) OrLessOrEqual ¶ added in v0.6.0
func (predicate Predicate) OrLessOrEqual(name string, value any) Expression
OrLessOrEqual combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) OrLessThan ¶ added in v0.6.0
func (predicate Predicate) OrLessThan(name string, value any) Expression
OrLessThan combines this predicate with another one (created from the arguments) into an Expression
func (Predicate) OrNotEqual ¶ added in v0.6.0
func (predicate Predicate) OrNotEqual(name string, value any) Expression
OrNotEqual combines this predicate with another one (created from the arguments) into an Expression