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

compileSQLite.md

42 lines979 Bytes

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