DocsData

History and AS OF

Every change kept, with who made it, when and why, and any collection read as it stood.

With history on, Sluurp logs every change in the same transaction as the write: the record’s new version, who changed it, when, and why. To turn it on, set "history": true on the collection, or switch it on in the admin:

schema.json
{ "name": "prices", "history": true, "schema": [ … ] }

Sluurp logs the existing rows once as a starting point, so the history is complete from the first moment.

Features include:

  • Any collection read as it stood at a moment (asOf), aggregates included
  • Each record’s versions, and any of them restored
  • A reason with every change
  • SQL:2011 FOR SYSTEM_TIME AS OF in the admin’s SQL console

Read the past

To read a collection as it stood, pass asOf. To read one record’s versions, newest first, call history(), and to put one back, restore():

app.ts
// the collection as it stood at the end of June
await sluurp.collection("prices").list({ asOf: "2026-06-30" });

// one record's versions, newest first, and restoring one
await sluurp.collection("prices").history(id);
await sluurp.collection("prices").restore(id, seq, { reason: "Undo" });

Over HTTP, asOf works on aggregates too, and /changes lists every change in order:

GET /api/collections/prices/aggregate?op=avg&field=value&group=product&asOf=2026-06-30

// every change, in order
GET /api/collections/prices/changes?since=0

Each past version is checked against the collection’s view rule as it applied to that version, so history never shows anything the reader couldn’t have seen.

Performance

Sluurp rebuilds a past moment once and caches it, so paging through it or asking again is fast. The server keeps a few moments per collection. If too many new ones are asked for at once, the extra requests get 429 Too Many Requests and can try again a second later, so time travel never slows down everyone else.

Give a reason

To say why a change was made, pass reason:

app.ts
await sluurp.collection("prices").update(id, { value: 7 }, { reason: "Supplier price rise" });

Over HTTP, use the X-Sluurp-Reason header. A batch gives one reason to all its changes.

Query the past in SQL

The SQL console in the admin understands SQL:2011’s temporal syntax. Plain queries still read the latest rows.

SELECT product, avg(value)
FROM prices FOR SYSTEM_TIME AS OF '2026-06-30'
GROUP BY product;

Before the query reaches SQLite, Sluurp swaps each such table for its past moment, rebuilt from the change log under the same name.

Pages

The version history of Pages uses the same log: who changed a page, when and why. Restoring a page puts back one of its versions.

View as Markdown