safing-portbase/database/query
2022-09-28 22:37:54 +02:00
..
condition-and.go Clean up database/query package 2019-09-20 22:01:17 +02:00
condition-bool.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
condition-error.go Update import paths 2019-06-27 13:29:56 +02:00
condition-exists.go Update import paths 2019-06-27 13:29:56 +02:00
condition-float.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
condition-int.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
condition-not.go Update import paths 2019-06-27 13:29:56 +02:00
condition-or.go Clean up database/query package 2019-09-20 22:01:17 +02:00
condition-regex.go Update import paths 2019-06-27 13:29:56 +02:00
condition-string.go Update import paths 2019-06-27 13:29:56 +02:00
condition-stringslice.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
condition.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
condition_test.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
operators.go Finish query package for now 2018-08-31 17:11:59 +02:00
operators_test.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
parser.go Fix linter errors 2022-09-28 22:37:54 +02:00
parser_test.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
query.go Clean up database/query package 2019-09-20 22:01:17 +02:00
query_test.go Fix tests and linter warnings 2022-02-01 13:12:46 +01:00
README.md Add GetMeta to database storage interface 2021-05-11 14:57:53 +02:00

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

Name Textual Req. Type Internal Type Compared with
Equals == int int64 ==
GreaterThan > int int64 >
GreaterThanOrEqual >= int int64 >=
LessThan < int int64 <
LessThanOrEqual <= int int64 <=
FloatEquals f== float float64 ==
FloatGreaterThan f> float float64 >
FloatGreaterThanOrEqual f>= float float64 >=
FloatLessThan f< float float64 <
FloatLessThanOrEqual f<= float float64 <=
SameAs sameas, s== string string ==
Contains contains, co string string strings.Contains()
StartsWith startswith, sw string string strings.HasPrefix()
EndsWith endswith, ew string string strings.HasSuffix()
In in string string for loop with ==
Matches matches, re string string regexp.Regexp.Matches()
Is is bool* bool ==
Exists exists, ex any n/a n/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.

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