- Core API Reference
- Collection
- createCollection
- liveQueryCollectionOptions
- createLiveQueryCollection
- createOptimisticAction
- createTransaction
- Electric DB Collection
- electricCollectionOptions
- Query DB Collection
- queryCollectionOptions
- RxDB DB Collection
- rxdbCollectionOptions
- PowerSync Collection
- powerSyncCollectionOptions
- createIndexedDB
- indexedDBCollectionOptions
- React Hooks
- useLiveQuery
Context
Defined in: packages/db/src/query/builder/types.ts:47
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 the from() clause
- schema: Current available tables (expands with joins, contracts with subqueries)
Query State:
- fromSourceName: Which table was used in from() or the first unionAll() source - needed for optionality logic
- hasJoins: 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 after select() - undefined until select is called
The context evolves through the query builder chain:
- from() sets baseSchema and schema to the same thing
- join() expands schema and sets hasJoins/joinTypes
- select() sets result to the projected shape
Properties#
baseSchema#
baseSchema: ContextSchema;Defined in: packages/db/src/query/builder/types.ts:49
fromSourceName#
fromSourceName: string;Defined in: packages/db/src/query/builder/types.ts:55
fromSourceNames?#
optional fromSourceNames: readonly string[];Defined in: packages/db/src/query/builder/types.ts:57
hasJoins?#
optional hasJoins: boolean;Defined in: packages/db/src/query/builder/types.ts:61
hasResult?#
optional hasResult: true;Defined in: packages/db/src/query/builder/types.ts:70
hasUnionFrom?#
optional hasUnionFrom: true;Defined in: packages/db/src/query/builder/types.ts:59
joinTypes?#
optional joinTypes: Record<string, "inner" | "left" | "right" | "full" | "outer" | "cross">;Defined in: packages/db/src/query/builder/types.ts:63
refsSchema?#
optional refsSchema: ContextSchema;Defined in: packages/db/src/query/builder/types.ts:53
result?#
optional result: any;Defined in: packages/db/src/query/builder/types.ts:68
schema#
schema: ContextSchema;Defined in: packages/db/src/query/builder/types.ts:51
singleResult?#
optional singleResult: boolean;Defined in: packages/db/src/query/builder/types.ts:72