Generated query resolvers
View as MarkdownCustom table adapters can reuse the same table-dependent boundary as generated routes. The server package exports:
resolvePageQuery(query, table, { auth, searchPlan });resolveExportQuery(query, table, { auth, searchPlan });resolveLookupQuery(query, table);resolveCountQuery(query, table);These functions accept the matching parsed shared-contract query and validate
table-dependent column, filter, lookup, search, and ordering semantics. The
export and lookup resolvers return the direct Drizzle-shaped input for the
matching scopedRows() operation.
A list read resolves to one of two plans. resolvePageQuery() returns a
ResolvedPageQuery:
const resolved = resolvePageQuery(query, table, { auth, searchPlan });if (resolved.kind === "rows") return rows.page(resolved.input);
const match = await rows.treeMatch(resolved.treeMatch);const result = await rows.page({ ...resolved.page, where: match.where });return { data: result.data, meta: { ...result.meta, tree: { matchCount: match.matchCount, contextIds: match.contextIds }, },};{ kind: "rows", input }is apage()input whosewherecombines thefixed[...]conditions, thefilter[...]conditions, andq.{ kind: "treeMatch", treeMatch, page }is returned for atreeread with a filter or search on a table that declaresmeta.tree.treeMatchholds thefixedandmatchpredicates and thematchContext.pageholds the ordering and paging without awhere. PasstreeMatchtoscopedRows().treeMatch(), then page over thewhereit returns.meta.totalthen counts the matches together with their ancestors and descendants. The generated list route reportsmatchCountandcontextIdsasmeta.tree, as the example does.
Count needs one more choice:
const resolved = resolveCountQuery(query, table);const data = resolved.kind === "total" ? await rows.count(resolved.input) : await rows.countBy(resolved.input);That ResolvedCountQuery discriminator selects count() or countBy() without
putting HTTP grammar into either data method. These resolvers are the right
bridge when an adapter owns that grammar. Ordinary domain code should construct
its Drizzle predicate directly instead of manufacturing filter[...],
fixed[...], q, or numeric query strings.
The corresponding public types include ResolvedPageQuery,
ResolvedCountQuery, and ResolveRowsQueryOptions.