SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Typescript query builder

Open jsdt opened this issue 2 months ago • 0 comments

Description of Changes

This introduces a query builder for typescript modules. It is available as ReducerCtx.queryBuilder, but it might make more sense to rename that to schema. There are some examples of how to build queries in query.test-d.ts and query.test.ts.

There is more type-safety to be added (ensuring eq is used on comparable types, and only allowing semijoins to use indexed columns), but those changes should only require changing some type parameters.

API and ABI breaking changes

This is adding a new query builder API on the module side, which won't actually be useful until we can use them in views.

Expected complexity level and risk

1.5.

Testing

There are tests of the emitted sql in query.test.ts, but at some point we should add end-to-end tests to make sure that we can parse those queries in the query engine.

jsdt avatar Nov 11 '25 05:11 jsdt