Getting Started

Tutorial: Building with CleaveDB

Filtering Results

A structured query becomes useful when its conditions match the way the application thinks about its data. CleaveQL gives SCOOP three ways to express those conditions: WHERE compares field values, WHOSE states an exact field match in plain language, and MATCHING describes a JSON shape to match. Choose the form that makes the rule easiest to read and maintain.

Compare values with WHERE

Place a field, comparison, and value after WHERE. SCOOP supports equality and inequality (=, !=) plus the numeric comparisons >, <, >=, and <=. Combine conditions with AND when all must hold, or OR when either condition qualifies. This is the everyday way to narrow a large bucket to a useful set.

CleaveQLExample · Combine structured conditions
SCOOP users WHERE age > 21
SCOOP users WHERE age > 21 AND city = "Manila"
SCOOP users WHERE age < 20 OR city = "Cebu"

The first query asks for adults over the chosen age threshold. The second adds a city requirement, so both conditions must match. The third widens the result: a user qualifies by being under 20 or by living in Cebu. These small operators let one query express a clear rule instead of retrieving every document and repeating the same checks in application code.

State an exact match with WHOSE

For a direct equality-style question, WHOSE reads naturally: “SCOOP users whose name is Jane.” It works well when the field and its exact value are the whole condition, such as a known status, department, or profile name.

CleaveQLExample · Match an exact field
SCOOP users WHOSE name IS "Jane"
SCOOP employees WHOSE department IS "Design"

Use WHOSE to make a simple exact match easy to scan. Reach for WHERE when the comparison is numeric, uses a different operator, or needs multiple conditions. Both forms help SCOOP target documents before it shapes the returned set.

Match a JSON template

MATCHING lets a query describe a JSON template. Use it when the shape and values of a small object communicate the desired document more clearly than separate field clauses—for example, a city value or a combination of known attributes.

CleaveQLExample · Match a JSON shape
SCOOP users MATCHING {"city": "Manila"}
SCOOP products MATCHING {"category": "Books", "available": true}

Keep the template focused on the fields that define the match. Use WHERE for comparisons and boolean logic; use MATCHING when a compact JSON pattern is the clearest description of the record you want.