Where Clause

The where clauses of paired map or reduce functions share the same specification and filter inputs like other query systems.

Note that the map and reduce where definition does not produce the same result and not all parameters are valid.

Where clause examples

{
  "version": "1.7.0",
  "event": {
      "game": {
          "maps": [
              {
                  "id": "changeColor",
                  "source": "userinput",
                  "where": {"key": ["changeColor", "<name>"], "name": "<color>", "type": "string"},
                  "key": ["changeColor", "<name>", "<color>"], "value": 1
              },
              {
                  "id": "cheer",
                  "source": "userinput",
                  "where": {"key": ["cheer"], "name": "<name>", "type": "string"},
                  "key": ["cheer", "<name>"], "value": 1
              }
          ],
          "reductions": [
              {
                  "id": "changeColor",
                  "where": {"key": ["changeColor", "<name>", "<color>"]},
                  "key": ["<name>", "<color>"],
                  "value": ["$count"],
                  "period": 250
              },
              {
                  "id": "cheer",
                  "where": {"key": ["cheer", "<name>"]},
                  "key": ["<name>"],
                  "value": ["$sum"],
                  "period": 250
              }
          ]
      }
  }
}

Where clause content

Specifies the conditions for matching key:value pairs. Conditions includes:

key

An array of strings. It needs to be placed inside brackets. It can contains multiples values seperated by a comma. If a value is a string, the event will need to match this exact value. If the value is string with with <>, it will take any value. Note that you can reference this value later on with the tag between the <>

{"key": ["changeColor", "<name>", "<color>"]}

name

The tag name of the value.

type

The type of value sent. This value needs to be either a bool, a string or a number (float64 is used for map and reduce purpose in case of a number). This is only useful if you intend to use the filter operations listed below.

Filter operations

You can also filter the value with these options depending of their type:

any type:

  • $or: The value must match at least one where clause in an array of where clauses.

bool:

  • $eq: The value must equals the specified value.

number:

  • $eq: The value must equals the specified value.
  • $neq: The value doesn’t equal the specified value.
  • $gt: The value is greater than the specified value.
  • $gte: The value is greater than or equal to the specified value.
  • $lt: The value is less than the specified value.
  • $lte: The value is less than or equal to the specified value.

string:

  • $caseSensitive: Modifies a search to be case sensitive. Can be combined with the filter operations below.
  • $in: The value must match one item in the array.
  • $searchIn: The value must contain at least one of the listed strings.
  • $search: The value must contain the search string.
  • $eq: The value must equals the specified value.
  • $neq: The value doesn’t equal the specified value.