| id | Context |
|---|---|
| title | Context |
Defined in: packages/db/src/query/builder/types.ts:35
Context - The central state container for query builder operations
This interface tracks all the information needed to build and type-check queries:
Schema Management:
baseSchema: The original tables/collections from thefrom()clauseschema: Current available tables (expands with joins, contracts with subqueries)
Query State:
fromSourceName: Which table was used infrom()- needed for optionality logichasJoins: Whether any joins have been added (affects result type inference)joinTypes: Maps table aliases to their join types for optionality calculations
Result Tracking:
result: The final shape afterselect()- undefined until select is called
The context evolves through the query builder chain:
from()sets baseSchema and schema to the same thingjoin()expands schema and sets hasJoins/joinTypesselect()sets result to the projected shape
baseSchema: ContextSchema;Defined in: packages/db/src/query/builder/types.ts:37
fromSourceName: string;Defined in: packages/db/src/query/builder/types.ts:41
optional hasJoins: boolean;Defined in: packages/db/src/query/builder/types.ts:43
optional joinTypes: Record<string, "inner" | "left" | "right" | "full" | "outer" | "cross">;Defined in: packages/db/src/query/builder/types.ts:45
optional result: any;Defined in: packages/db/src/query/builder/types.ts:50
schema: ContextSchema;Defined in: packages/db/src/query/builder/types.ts:39
optional singleResult: boolean;Defined in: packages/db/src/query/builder/types.ts:52