Getting Started
Tutorial: Building with CleaveDB
Chaining Stages
In CleaveQL, the THEN keyword links transformation stages into a coherent stream. Each stage consumes records produced by the prior stage, applies its transformation, and forwards the results onward.
Anatomy of a complete pipeline
You can chain filtering, sorting, pagination, and projection together in a single readable command:
CleaveQLExample · Four-stage processing pipeline
PIPE FROM users
THEN WHERE age > 20
THEN ARRANGED BY age GOING DOWN
THEN LIMIT 3
THEN SHOW name, ageHere is what happens during execution:
PIPE FROM users: Streams records from theusersbucket into the pipeline.THEN WHERE age > 20: Discards documents whereage <= 20.THEN ARRANGED BY age GOING DOWN: Orders surviving records in descending order of age.THEN LIMIT 3: Halts the stream after the top 3 items are emitted.THEN SHOW name, age: Strips all internal metadata and other document fields, returning onlynameandage.
Immediate post-write pipelines
CleaveDB allows executing a PIPE query immediately following a write command (like POUR) on the exact same line. This lets you insert a document and immediately query the updated dataset in one atomic roundtrip:
CleaveQLExample · Insert and pipe on one line
POUR INTO emp "z1" {"name": "Zed", "age": 50, "dept": "IT"} PIPE FROM emp THEN WHERE age > 45 THEN SHOW nameThis pattern is common for command-query operations where a client needs to confirm the state of the bucket right after creating a record.
