HTTP endpoint
Request
| Field | Type | Required | Description |
|---|---|---|---|
from | string | ✓ | Glob pattern matched against CRDT IDs. * matches any sequence of characters. |
type | string | — | Filter by CRDT type. When omitted, inferred from the from prefix (e.g. gc: → gcounter). |
aggregate | string | ✓ | Aggregation function. Must be compatible with the matched CRDT types. |
where | object | — | Optional content filter applied before aggregation. |
Response
| Field | Description |
|---|---|
value | Aggregated result. Shape depends on aggregate. null when nothing matched. |
matched | Number of CRDTs that passed glob + type + where filters. |
scanned | Total number of CRDTs scanned in the namespace. |
execution_ms | Server-side wall-clock execution time in milliseconds. |
Aggregations by CRDT type
| CRDT type | type value | Supported aggregations |
|---|---|---|
| GCounter | gcounter | sum, max, min, count |
| PNCounter | pncounter | sum, max, min, count |
| ORSet | orset | union, intersection, count |
| LwwRegister | lwwregister | latest, collect |
| Presence | presence | union, count |
| CRDTMap | crdtmap | collect |
| RGA | rga | collect |
| Tree | tree | collect |
from: "*" without a type filter) and using a type-specific aggregation returns 400 incompatible_aggregate.
Examples
Sum all page view counters
Count how many carts contain a product
Union all carts
Latest config value across all regions
Config registers updated in the last minute
where clause
| Field | Applicable to | Description |
|---|---|---|
contains | ORSet | Only include sets that contain this JSON value (exact match). |
updatedAfter | LwwRegister | Only include registers updated after this Unix timestamp in ms. |
SDK — client.query()
Fluent type inference
Theaggregate field is typed as a string literal union — TypeScript will catch invalid combinations at compile time when you use the QuerySpec type directly.
React — useQuery()
useQuery re-runs the query when spec changes. Use useMemo to stabilize the spec object and avoid unnecessary requests on every render.
Key IDs convention
The query engine matches on the full CRDT ID as stored — whatever string you pass toclient.gcounter(id), client.orset(id), etc. Using a prefix convention like gc:views-homepage makes glob patterns predictable and enables type inference from the pattern.
| Prefix | Inferred type |
|---|---|
gc: | gcounter |
pn: | pncounter |
or: | orset |
lw: | lwwregister |
pr: | presence |
cm: | crdtmap |
rga: | rga |
tree: | tree |