Skip to main content
The Query Engine lets you aggregate data across multiple CRDTs in a single HTTP request. Instead of reading CRDTs one by one, you can sum all page view counters, union all shopping carts, or find the latest config register — with a single query scoped to a namespace.

HTTP endpoint

Request

Response


Aggregations by CRDT type

Mixing CRDT types in a single query (e.g. 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


SDK — client.query()

Fluent type inference

The aggregate 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 to client.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.
Type inference from prefix: