Skip to content

Commit 3404531

Browse files
Add comprehensive deparse documentation to README Usage section
- Add deparse(parseTree: ParseResult): Promise<string> async function documentation - Add deparseSync(parseTree: ParseResult): string sync function documentation - Include proper TypeScript examples with ParseResult type usage - Add import { ParseResult } from '@pgsql/types' type import as requested - Complete API documentation now covers parsing and deparsing functionality Co-Authored-By: Dan Lynch <[email protected]>
1 parent 7e9043a commit 3404531

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,32 @@ import { parsePlPgSQLSync } from 'libpg-query';
8989
const result = parsePlPgSQLSync(functionSql);
9090
```
9191

92+
### `deparse(parseTree: ParseResult): Promise<string>`
93+
94+
Converts a parse tree back to SQL string. Returns a Promise for the SQL string.
95+
96+
```typescript
97+
import { parseQuery, deparse } from 'libpg-query';
98+
import { ParseResult } from '@pgsql/types';
99+
100+
const parseTree = await parseQuery('SELECT * FROM users WHERE active = true');
101+
const sql = await deparse(parseTree[0]);
102+
// Returns: string - reconstructed SQL query
103+
```
104+
105+
### `deparseSync(parseTree: ParseResult): string`
106+
107+
Synchronous version that converts a parse tree back to SQL string directly.
108+
109+
```typescript
110+
import { parseQuerySync, deparseSync } from 'libpg-query';
111+
import { ParseResult } from '@pgsql/types';
112+
113+
const parseTree = parseQuerySync('SELECT * FROM users WHERE active = true');
114+
const sql = deparseSync(parseTree[0]);
115+
// Returns: string - reconstructed SQL query
116+
```
117+
92118
### Type Definitions
93119

94120
```typescript

0 commit comments

Comments
 (0)