Schemas

The schema is written in JSON and contains the definition for your events. It is divided with the map and reduce portion. Note that the where clause is present for both the map and reduce.

In This Section

Schema example

{
  "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
              }
          ]
      }
  }
}

Schema content

In your schema, the document must be made with this exact structure:

First depth level

  1. A version field is present and it needs to be 1.7.0.
  2. An event field that contains the rest of the definition.

Second depth level

A game field that contains the map and reduce portions.

Third depth level

  1. A maps field which contains your map definition.
  2. A reductions field which contains your reduce definition.

Map and reduce both use the where clause to filter through the results. Note that it is possible to divide the map and reduce into their own documents, so it is not mandatory to have both placed inside the same document.