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

compileSQLite.md

40 lines950 Bytes

1---
2id: compileSQLite
3title: compileSQLite
4---
5​
6```ts
7function compileSQLite(options, compileOptions?): SQLiteCompiledQuery;
8```
9​
10Defined in: [sqlite-compiler.ts:45](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L45)
11​
12Compiles TanStack DB LoadSubsetOptions to SQLite query components.
13​
14## Parameters
15​
16### options
17​
18`LoadSubsetOptions`
19​
20### compileOptions?
21​
22[`CompileSQLiteOptions`](../interfaces/CompileSQLiteOptions.md)
23​
24## Returns
25​
26[`SQLiteCompiledQuery`](../interfaces/SQLiteCompiledQuery.md)
27​
28## Example
29​
30```typescript
31const compiled = compileSQLite({
32 where: { type: 'func', name: 'gt', args: [
33 { type: 'ref', path: ['price'] },
34 { type: 'val', value: 100 }
35 ]},
36 orderBy: [{ expression: { type: 'ref', path: ['price'] }, compareOptions: { direction: 'desc', nulls: 'last' } }],
37 limit: 50
38})
39// Result: { where: '"price" > ?', orderBy: '"price" DESC', limit: 50, params: [100] }
40```