Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

compileQuery.md

100 lines2.0 KB

1---
2id: compileQuery
3title: compileQuery
4---
5​
6# Function: compileQuery()
7​
8```ts
9function compileQuery(
10 rawQuery,
11 inputs,
12 collections,
13 subscriptions,
14 callbacks,
15 lazySources,
16 optimizableOrderByCollections,
17 setWindowFn,
18 cache,
19 queryMapping,
20 parentKeyStream?,
21 childCorrelationField?): CompilationResult;
22```
23​
24Defined in: [packages/db/src/query/compiler/index.ts:130](https://github.com/TanStack/db/blob/main/packages/db/src/query/compiler/index.ts#L130)
25​
26Compiles a query IR into a D2 pipeline
27​
28## Parameters
29​
30### rawQuery
31​
32[`QueryIR`](../@tanstack/namespaces/IR/interfaces/QueryIR.md)
33​
34The query IR to compile
35​
36### inputs
37​
38`Record`\<`string`, [`KeyedStream`](../type-aliases/KeyedStream.md)\>
39​
40Mapping of source aliases to input streams (e.g., `{ employee: input1, manager: input2 }`)
41​
42### collections
43​
44`Record`\<`string`, [`Collection`](../interfaces/Collection.md)\<`any`, `any`, `any`, `any`, `any`\>\>
45​
46Mapping of collection IDs to Collection instances
47​
48### subscriptions
49​
50`Record`\<`string`, `CollectionSubscription`\>
51​
52Mapping of source aliases to CollectionSubscription instances
53​
54### callbacks
55​
56`Record`\<`string`, `LazyCollectionCallbacks`\>
57​
58Mapping of source aliases to lazy loading callbacks
59​
60### lazySources
61​
62`Set`\<`string`\>
63​
64Set of source aliases that should load data lazily
65​
66### optimizableOrderByCollections
67​
68`Record`\<`string`, `OrderByOptimizationInfo`\>
69​
70Map of collection IDs to order-by optimization info
71​
72### setWindowFn
73​
74(`windowFn`) => `void`
75​
76### cache
77​
78`QueryCache` = `...`
79​
80Optional cache for compiled subqueries (used internally for recursion)
81​
82### queryMapping
83​
84`QueryMapping` = `...`
85​
86Optional mapping from optimized queries to original queries
87​
88### parentKeyStream?
89​
90[`KeyedStream`](../type-aliases/KeyedStream.md)
91​
92### childCorrelationField?
93​
94[`PropRef`](../@tanstack/namespaces/IR/classes/PropRef.md)\<`any`\>
95​
96## Returns
97​
98`CompilationResult`
99​
100A CompilationResult with the pipeline, source WHERE clauses, and alias metadata