Browse the docs

Keep a record in the kit

Reads, saves, deletes or lists the records a Site Kit keeps (notes, counts, what you saw last), shared with the kit's pages in every browser.

op key in collection

Details #

A Site Kit keeps its own records in Switchboard, not in the website. Each record has a collection (a group, like notes), a key and a value (text, a number, a list or a record). A kit's pages read and write the same records with kit.store, and a change shows up at once in every open tab of the kit, in every connected browser.

  • get reads the record at key (nothing if there is none).

  • put saves value at key.

  • delete removes the record.

  • query lists the records of the collection, in key order, as {key, value}. prefix keeps only keys that start with it.

kit is the kit's id (kit.github-plus); leave it out for the kit this macro is in. A value can be up to 1 MB and a collection holds up to 10,000 records. Collections that start with __ belong to the kit itself and can't be changed here.

The kit's settings are not records: read them in any text with {{ kit.setting.compact }}.

Records stay when the kit is turned off or updated. They are deleted only with the kit, after Switchboard has said how many there are.

Parameters #

ParameterTypeRequiredValuesWhat it does
collectiontext, key, value, prefix: What to read or save.
intotextThe variable that receives the result: the value, true, or the list of {key, value}.
keytext
kittextWhich kit. Default: the kit this macro is in.
opone ofget put delete queryget, put, delete or query.
prefixtext
sampleany value
valueany value

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Remember a note, then read it back
Do
  1. Save “pr-12” to “notes”
  2. Read “pr-12” from “notes”
Open in Switchboard to try it

Gotchas #

  • A macro outside a Site Kit has to name the kit with kit.

  • A put past 1 MB or 10,000 records fails and says which limit it hit.