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

walkExpression.md

41 lines744 Bytes

1---
2id: walkExpression
3title: walkExpression
4---
5​
6```ts
7function walkExpression(expr, visitor): void;
8```
9​
10Defined in: [packages/db/src/query/expression-helpers.ts:153](https://github.com/TanStack/db/blob/main/packages/db/src/query/expression-helpers.ts#L153)
11​
12Generic expression tree walker that visits each node in the expression.
13Useful for implementing custom parsing logic.
14​
15## Parameters
16​
17### expr
18​
19The expression to walk
20​
21`BasicExpression`\<`any`\> | `null` | `undefined`
22​
23### visitor
24​
25(`node`) => `void`
26​
27Visitor function called for each node
28​
29## Returns
30​
31`void`
32​
33## Example
34​
35```typescript
36walkExpression(whereExpr, (node) => {
37 if (node.type === 'func' && node.name === 'eq') {
38 console.log('Found equality comparison')
39 }
40})
41```