pg-ast 0.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Dan Lynch <pyramation@gmail.com>
3
+ Copyright (c) 2024 Dan Lynch <pyramation@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,40 @@
1
- # pg-ast
1
+ # pg-ast ![Build Status](https://travis-ci.org/pyramation/pg-ast.svg?branch=master)
2
2
 
3
3
  Create PostgreSQL ASTs with JavaScript
4
4
 
5
- Zero Dependencies ;)
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install pg-ast
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import * as ast from 'pg-ast';
15
+ const node = ast.A_Expr({
16
+ kind: 0,
17
+ name: [ast.String({ str: '=' })],
18
+ lexpr: ast.Integer({ ival: 0 }),
19
+ rexpr: ast.Integer({ ival: 0 })
20
+ });
21
+ ```
22
+
23
+ ## Pairs well with `pgsql-parser`
24
+
25
+ https://github.com/pyramation/pgsql-parser
26
+
27
+ You can create ASTs manually, and then generate your SQL:
28
+
29
+ ```js
30
+ import * as ast from '../src';
31
+ import { deparse } from 'pgsql-parser';
32
+
33
+ const node = ast.A_Expr({
34
+ kind: 0,
35
+ name: [ast.String({ str: '=' })],
36
+ lexpr: ast.Integer({ ival: 0 }),
37
+ rexpr: ast.Integer({ ival: 0 })
38
+ });
39
+ const sqlCode = deparse([node]);
40
+ ```