# Dataset presets

Drop JSON files here (or point `KVGUI_PRESETS_DIR` to another folder) to add sample queries and key
descriptions for a known key layout. A preset is used for a connection when every key in its `detect`
list exists there. Files are read on each page load, no restart needed.

Example: [`demo/vulnerability-lookup/presets/vulnerability-lookup.json`](../../demo/vulnerability-lookup/presets/vulnerability-lookup.json).

| Field | Meaning |
|---|---|
| `name`, `description` | Shown in the Sample queries and Key statistics tabs |
| `detect` | Keys that must all exist for the preset to apply |
| `missingHint` | Shown when the preset is picked but its keys are missing |
| `indexPattern`, `indexLabel` | Regex of the sorted sets listed as indexes in Key statistics |
| `keyPattern` | Regex of values that are key names (clickable in query results) |
| `dateScoreKeys` | Regex of sorted sets whose scores are Unix timestamps (shown as dates) |
| `describe` | `[regex, text]` pairs describing key patterns; first match wins |
| `params` | `{ name, label, default?, options?, from? }`; `from` is a command whose first reply value becomes the default |
| `queries` | `{ group, title, desc?, steps }`; each step is a command as a token list |

In `default`, titles, descriptions and steps, `{name}` is replaced by a parameter, `{prev}` by the
previous step's reply, and `{currentYear}`, `{currentMonth}` and `{since}` (now minus `days` days, in
Unix seconds) are always available.
