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

walkExpression.md

43 lines774 Bytes

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