Skip to content

Commit 0ee2cf4

Browse files
committed
readme
1 parent b0efbda commit 0ee2cf4

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

packages/proto-parser/README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,9 @@ Each of these options can be set when initializing the `PgProtoParser` to custom
256256
It generates code with syntax for [@pgsql/utils](https://github.com/launchql/pgsql-parser/tree/main/packages/utils), using runtime schema information to determine whether nodes should be wrapped (`t.nodes.*`) or unwrapped (`t.ast.*`).
257257

258258
```ts
259-
import {
260-
generateTsAstCodeFromPgAst
261-
} from 'pg-proto-parser';
259+
import { generateTsAstCodeFromPgAst } from 'pg-proto-parser';
260+
import { runtimeSchema } from './path/to/your/generated/runtime-schema';
262261
import { parse } from 'pgsql-parser';
263-
import { runtimeSchema } from 'pg-proto-parser/runtime-schema';
264262

265263
// Example SQL query
266264
const sql = 'SELECT * FROM my_table WHERE id = 1';
@@ -279,33 +277,33 @@ console.log(tsAstBuilderCode);
279277
// make sure to use this import when using
280278
// import ast from '@pgsql/utils';
281279

282-
ast.selectStmt({
283-
targetList: [ast.resTarget({
284-
val: ast.columnRef({
285-
fields: [ast.aStar({})],
280+
t.nodes.selectStmt({
281+
targetList: [t.nodes.resTarget({
282+
val: t.nodes.columnRef({
283+
fields: [t.nodes.aStar({})],
286284
location: 7
287285
}),
288286
location: 7
289287
})],
290-
fromClause: [ast.rangeVar({
288+
fromClause: [t.nodes.rangeVar({
291289
relname: "my_table",
292290
inh: true,
293291
relpersistence: "p",
294292
location: 14
295293
})],
296-
whereClause: ast.aExpr({
294+
whereClause: t.nodes.aExpr({
297295
kind: "AEXPR_OP",
298-
name: [ast.string({
299-
str: "="
296+
name: [t.nodes.string({
297+
sval: "="
300298
})],
301-
lexpr: ast.columnRef({
302-
fields: [ast.string({
303-
str: "id"
299+
lexpr: t.nodes.columnRef({
300+
fields: [t.nodes.string({
301+
sval: "id"
304302
})],
305303
location: 29
306304
}),
307-
rexpr: ast.aConst({
308-
val: ast.integer({
305+
rexpr: t.nodes.aConst({
306+
ival: t.ast.integer({
309307
ival: 1
310308
}),
311309
location: 34

0 commit comments

Comments
 (0)