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' } } |
$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 } } |
Combine operators on one field with an object:
Nested or / top-level arbitrary AND/OR grouping is roadmapped. For v0.1,
compose on the client: run two narrower query() calls and merge, or pass
result IDs to a follow-up call. For complex filters that a human would write
in SQL — reach for include with where on the
joined lens, or use a view in your source DB.
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.