Query — Predicates
The where clause accepts a Record<string, unknown>. At the top level, keys
AND together; per-field values can be a literal (equality) or an object with
one of the supported operators.
Equality
The simplest shape. Direct equality on one or more fields:
Top-level keys always AND.
Operators
Wrap a value in an object to use a range or set operator. The grammar uses
Mongo-style $ prefixes:
| Operator | Meaning | Example |
|---|---|---|
$eq | Equal (rarely needed — bare value works) | { status: { $eq: 'open' } } |
$ne | Not equal | { status: { $ne: 'closed' } } |
$in | Value is one of an array | { status: { $in: ['open', 'triaged'] } } |
$gt, $gte | Greater than, greater-or-equal | { rating: { $gte: 4 } } |
$lt, $lte | Less than, less-or-equal | { price: { $lt: 100 } } |
$ilike, $like | Case-insensitive / case-sensitive substring (% and _ wildcards) | { title: { $ilike: '%curry%' } } |
$exists | Field is non-null | { deleted_at: { $exists: false } } |
Combine operators on one field with an object:
Logical composition — $or, $and, $not
Top-level keys still AND together by default. To compose more complex
predicates, drop in $or, $and, or $not:
The grammar is shared across query, count, analyze.candidates.where,
analyze drill-down search, and the streaming exports — one operator
vocabulary, every read surface.
Bridge capabilities differ. Postgres / MySQL / SQLite / Mongo /
ClickHouse / Redis / DynamoDB / Firestore / Elasticsearch / Cassandra
all support the full operator set as of @semilayer/bridge-resolver@1.5.0.
Older bridge versions or community bridges may reject $or / $ilike —
the service catches the bridge-side UnsupportedOperatorError and
returns 400 unsupported_operator with the offending operator + bridge
name in the body.
Full example
orderBy
A single rule or an array (applied in order):
Default direction is 'asc'. Default ordering is whatever the bridge returns
if you omit orderBy entirely — which is not guaranteed stable for
pagination. Always set orderBy if you're going to paginate.
select
Restrict the projection to specific fields. Cheaper over the wire and often cheaper to compute.
Omit select to get all fields declared on the lens. Selecting a field not
declared on the lens is a validation error (422).
Beyond: joining across lenses
For "products with their recent reviews", reach for include:
The full join grammar lives in Joins → Include Syntax.
Next: Pagination — handling more rows than fit in a single response.