feat(db): add type-level queryable field constraints#1225
feat(db): add type-level queryable field constraints#1225ajoslin wants to merge 1 commit intoTanStack:mainfrom
Conversation
Allow where/orderBy refs to be constrained to policy-safe subsets while preserving full result model types and existing behavior when queryable is not configured.
|
|
Hey @ajoslin This looks interesting and I can see the real need for it. Currently you are defining the queryable fields on the liveQueryCollection, not on the source collection. Would it be better to do it on the source collections so that they are not repeated? |
Hey, love Tanstack! here's a quick PR allowing separation of queryable/sortable types from returned types.
Summary
Problem: TanstackDB live query callbacks expose all model fields even when I want only allow a subset for filtering/sorting.
I return a lot of fields to the client from my API, using a query-backed collection with syncMode on demand. However, I don't want the client to be able to filter/sort by ALL of those fields, since not all of them can be efficiently queried on the backend.
The solution: add optional type-level queryable constraints so
where/orderByrefs can be restricted while result rows remain full objects.Non-invasive: additive typing only (
querySchema+ optionalqueryable/helper), defaults preserved, no runtime or planner behavior changes.Example