package
0.19.5
Repository: https://github.com/safing/portbase.git
Documentation: pkg.go.dev

# README

Query

Control Flow

  • Grouping with ( and )
  • Chaining with and and or
    • NO mixing! Be explicit and use grouping.
  • Negation with not
    • in front of expression for group: not (...)
    • inside expression for clause: name not matches "^King "

Selectors

Supported by all feeders:

  • root level field: field
  • sub level field: field.sub
  • array/slice/map access: map.0
  • array/slice/map length: map.#

Please note that some feeders may have other special characters. It is advised to only use alphanumeric characters for keys.

Operators

NameTextualReq. TypeInternal TypeCompared with
Equals==intint64==
GreaterThan>intint64>
GreaterThanOrEqual>=intint64>=
LessThan<intint64<
LessThanOrEqual<=intint64<=
FloatEqualsf==floatfloat64==
FloatGreaterThanf>floatfloat64>
FloatGreaterThanOrEqualf>=floatfloat64>=
FloatLessThanf<floatfloat64<
FloatLessThanOrEqualf<=floatfloat64<=
SameAssameas, s==stringstring==
Containscontains, costringstringstrings.Contains()
StartsWithstartswith, swstringstringstrings.HasPrefix()
EndsWithendswith, ewstringstringstrings.HasSuffix()
Ininstringstringfor loop with ==
Matchesmatches, restringstringregexp.Regexp.Matches()
Isisbool*bool==
Existsexists, exanyn/an/a

*accepts strings: 1, t, T, true, True, TRUE, 0, f, F, false, False, FALSE

Escaping

If you need to use a control character within a value (ie. not for controlling), escape it with \. It is recommended to wrap a word into parenthesis instead of escaping control characters, when possible.

LocationCharacters to be escaped
Within parenthesis (")", \
Everywhere else(, ), ", \, \t, \r, \n, (space)

# Functions

And combines multiple conditions with a logical _AND_ operator.
New creates a new query with the supplied prefix.
Not negates the supplied condition.
Or combines multiple conditions with a logical _OR_ operator.
ParseQuery parses a plaintext query.
Where returns a condition to add to a query.

# Constants

string.
string.
int.
any.
float.
float.
float.
float.
float.
int.
int.
stringSlice.
bool: accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE.
int.
int.
regex.
string.
string.

# Structs

Query contains a compiled query.

# Interfaces

Condition is an interface to provide a common api to all condition types.