github.com/safing/portbase@v0.19.5/database/query/README.md (about)

     1  # Query
     2  
     3  ## Control Flow
     4  
     5  - Grouping with `(` and `)`
     6  - Chaining with `and` and `or`
     7    - _NO_ mixing! Be explicit and use grouping.
     8  - Negation with `not`
     9    - in front of expression for group: `not (...)`
    10    - inside expression for clause: `name not matches "^King "`
    11  
    12  ## Selectors
    13  
    14  Supported by all feeders:
    15  - root level field: `field`
    16  - sub level field: `field.sub`
    17  - array/slice/map access: `map.0`
    18  - array/slice/map length: `map.#`
    19  
    20  Please note that some feeders may have other special characters. It is advised to only use alphanumeric characters for keys.
    21  
    22  ## Operators
    23  
    24  | Name                    | Textual            | Req. Type | Internal Type | Compared with             |
    25  |-------------------------|--------------------|-----------|---------------|---------------------------|
    26  | Equals                  | `==`               | int       | int64         | `==`                      |
    27  | GreaterThan             | `>`                | int       | int64         | `>`                       |
    28  | GreaterThanOrEqual      | `>=`               | int       | int64         | `>=`                      |
    29  | LessThan                | `<`                | int       | int64         | `<`                       |
    30  | LessThanOrEqual         | `<=`               | int       | int64         | `<=`                      |
    31  | FloatEquals             | `f==`              | float     | float64       | `==`                      |
    32  | FloatGreaterThan        | `f>`               | float     | float64       | `>`                       |
    33  | FloatGreaterThanOrEqual | `f>=`              | float     | float64       | `>=`                      |
    34  | FloatLessThan           | `f<`               | float     | float64       | `<`                       |
    35  | FloatLessThanOrEqual    | `f<=`              | float     | float64       | `<=`                      |
    36  | SameAs                  | `sameas`, `s==`    | string    | string        | `==`                      |
    37  | Contains                | `contains`, `co`   | string    | string        | `strings.Contains()`      |
    38  | StartsWith              | `startswith`, `sw` | string    | string        | `strings.HasPrefix()`     |
    39  | EndsWith                | `endswith`, `ew`   | string    | string        | `strings.HasSuffix()`     |
    40  | In                      | `in`               | string    | string        | for loop with `==`        |
    41  | Matches                 | `matches`, `re`    | string    | string        | `regexp.Regexp.Matches()` |
    42  | Is                      | `is`               | bool*     | bool          | `==`                      |
    43  | Exists                  | `exists`, `ex`     | any       | n/a           | n/a                       |
    44  
    45  \*accepts strings: 1, t, T, true, True, TRUE, 0, f, F, false, False, FALSE
    46  
    47  ## Escaping
    48  
    49  If you need to use a control character within a value (ie. not for controlling), escape it with `\`.
    50  It is recommended to wrap a word into parenthesis instead of escaping control characters, when possible.
    51  
    52  | Location | Characters to be escaped |
    53  |---|---|
    54  | Within parenthesis (`"`) | `"`, `\` |
    55  | Everywhere else | `(`, `)`, `"`, `\`, `\t`, `\r`, `\n`, ` ` (space) |