type RefsForContext<TContext> = { [K in keyof TContext["schema"]]: IsNonExactOptional<TContext["schema"][K]> extends true ? IsNonExactNullable<TContext["schema"][K]> extends true ? Ref<NonNullable<TContext["schema"][K]>, true> : Ref<NonUndefined<TContext["schema"][K]>, true> : IsNonExactNullable<TContext["schema"][K]> extends true ? Ref<NonNull<TContext["schema"][K]>, true> : Ref<TContext["schema"][K]> } & TContext["result"] extends object ? object : object;
Defined in: packages/db/src/query/builder/types.ts:394
RefsForContext - Creates ref proxies for all tables/collections in a query context
This is the main entry point for creating ref objects in query builder callbacks. For nullable join sides (left/right/full joins), it produces Ref<T, true> instead of Ref<T> | undefined. This accurately reflects that the proxy object is always present at build time (it's a truthy proxy that records property access paths), while the Nullable flag ensures the result type correctly includes | undefined.
Examples:
After select() is called, this type also includes $selected which provides access to the SELECT result fields via $selected.fieldName syntax.
TContext extends Context