Tutorial: Building with CleaveDB
Historical Reads
Sometimes the useful answer is not what a document says now, but what it said at an earlier point. SCOOP supports AS OF for a historical read, using a timestamp or a supported relative time such as yesterday. This lets an application inspect an earlier view while leaving the current document untouched.
Ask for an earlier view
Place AS OF after the bucket and provide the point in time to inspect. A relative expression is convenient for a human-facing report; a timestamp is appropriate when an application needs a precise historical moment. You can keep ordinary structured conditions on the same request to focus the past view on the records relevant to the question.
SCOOP EVERYTHING FROM users AS OF "yesterday"
SCOOP users WHERE status = "active" AS OF "2025-04-01T00:00:00Z"The first query requests the users bucket as it appeared yesterday. The second applies a status condition to a timestamped view. Historical reads are useful for audits, support investigations, and interfaces that need to explain how data looked before a later update.
Read history without changing the present
AS OF changes the time context of the read, not the stored record. Use it when the question is “what was true then?” For current state, leave the modifier out. As with every SCOOP query, the caller’s tenant and read permissions still define which historical data is available to return.
