Getting Started
Tutorial: Building with CleaveDB
Expiring Documents
A session token has a useful life; a verification code has a much shorter one. For records that should not remain available indefinitely, add EXPIRES IN to the POUR statement. This sets a time-to-live (TTL) on the document when it is written. Give the duration as a number and one supported unit: SECONDS, MINUTES, HOURS, or DAYS.
CleaveQLExample · Session and verification code lifetimes
POUR INTO sessions "token_123" {"user": "alice"} EXPIRES IN 5 MINUTES
POUR INTO verification RANDOM {"code": 5555} EXPIRES IN 24 HOURSRead the examples
The first line stores Alice’s session under the ID token_123 and gives it a five-minute lifetime. The second creates a verification document with a generated ID and a 24-hour lifetime. In both cases, the expiry duration belongs to that specific document write; choose it to match how long that particular piece of data should be useful.
