Skip to content

Commit

Permalink
docs: fix outdated example
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Dec 5, 2024
1 parent 157124b commit 3fd8728
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ Let's explore the `walk` function, ideal for AST traversal where you're only con
Each node passed to your visitor is wrapped in a `NodePath` instance, which tracks the parent node and provides type guards (e.g. `isSelectStmt`) for type narrowing. You can access the underlying node with `path.node`.

```ts
import { parseQuerySync, walk, NodeTag } from "@pg-nano/pg-parser"
import { parseQuerySync, walk, $ } from "@pg-nano/pg-parser"

walk(parseQuerySync(sql), (path) => {
walk(parseQuerySync(`SELECT foo FROM bar`), (path) => {
path.tag // string
path.node // the node object
path.parent // the parent node
Expand All @@ -67,7 +67,7 @@ walk(parseQuerySync(sql), (path) => {
walk(path.node.targetList, {
ColumnRef(path) {
const id = path.node.fields
.map((f) => (NodeTag.isString(f) ? f.String.sval : "*"))
.map((f) => ($.isString(f) ? f.String.sval : "*"))
.join(".")

console.log(id)
Expand Down

0 comments on commit 3fd8728

Please sign in to comment.