You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`@pgsql/enums` is a TypeScript library providing enum definitions for PostgreSQL AST nodes, primarily used in conjunction with [`pgsql-parser`](https://github.com/launchql/pgsql-parser). It offers a comprehensive and type-safe way to work with PostgreSQL enum values in query parsing and AST manipulation.
@@ -27,41 +27,23 @@ npm install @pgsql/enums
27
27
28
28
## Usage
29
29
30
-
`@pgsql/enums` provides TypeScript enum definitions for PostgreSQL Abstract Syntax Tree (AST) nodes. These enums are useful for constructing, analyzing, or manipulating ASTs in a type-safe manner with exact enum values.
31
-
32
-
Here are a few examples of how you can use these enums in your TypeScript projects:
33
-
34
-
### Using Enum Values
35
-
36
-
You can use the enums to work with specific PostgreSQL AST enum values:
30
+
Here's a simple example showing how to work with enums, converting between enum names and their numeric values:
Enums help ensure that you use correct PostgreSQL enum values:
35
+
// Get the numeric value of an enum
36
+
const tableValue =ObjectType.OBJECT_TABLE;
37
+
console.log(tableValue); // 41
55
38
56
-
```ts
57
-
import { CmdType, JoinType } from'@pgsql/enums';
58
-
59
-
const command = {
60
-
cmdType: CmdType.CMD_SELECT,
61
-
joinType: JoinType.JOIN_INNER
62
-
};
39
+
// Convert from value back to enum name
40
+
const enumName =ObjectType[41];
41
+
console.log(enumName); // "OBJECT_TABLE"
63
42
64
-
console.log(command);
43
+
// Use in comparisons
44
+
if (someNode.objectType===ObjectType.OBJECT_TABLE) {
45
+
console.log("This is a table object");
46
+
}
65
47
```
66
48
67
49
## Versions
@@ -89,4 +71,4 @@ Our latest is built with PostgreSQL 17 enum definitions.
89
71
90
72
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
91
73
92
-
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
74
+
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
`@pgsql/enums` is a TypeScript library providing enum definitions for PostgreSQL AST nodes, primarily used in conjunction with [`pgsql-parser`](https://github.com/launchql/pgsql-parser). It offers a comprehensive and type-safe way to work with PostgreSQL enum values in query parsing and AST manipulation.
@@ -27,41 +27,23 @@ npm install @pgsql/enums
27
27
28
28
## Usage
29
29
30
-
`@pgsql/enums` provides TypeScript enum definitions for PostgreSQL Abstract Syntax Tree (AST) nodes. These enums are useful for constructing, analyzing, or manipulating ASTs in a type-safe manner with exact enum values.
31
-
32
-
Here are a few examples of how you can use these enums in your TypeScript projects:
33
-
34
-
### Using Enum Values
35
-
36
-
You can use the enums to work with specific PostgreSQL AST enum values:
30
+
Here's a simple example showing how to work with enums, converting between enum names and their numeric values:
Enums help ensure that you use correct PostgreSQL enum values:
35
+
// Get the numeric value of an enum
36
+
const tableValue =ObjectType.OBJECT_TABLE;
37
+
console.log(tableValue); // 41
55
38
56
-
```ts
57
-
import { CmdType, JoinType } from'@pgsql/enums';
58
-
59
-
const command = {
60
-
cmdType: CmdType.CMD_SELECT,
61
-
joinType: JoinType.JOIN_INNER
62
-
};
39
+
// Convert from value back to enum name
40
+
const enumName =ObjectType[41];
41
+
console.log(enumName); // "OBJECT_TABLE"
63
42
64
-
console.log(command);
43
+
// Use in comparisons
44
+
if (someNode.objectType===ObjectType.OBJECT_TABLE) {
45
+
console.log("This is a table object");
46
+
}
65
47
```
66
48
67
49
## Versions
@@ -89,4 +71,4 @@ Our latest is built with PostgreSQL 17 enum definitions.
89
71
90
72
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
91
73
92
-
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
74
+
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
`@pgsql/enums` is a TypeScript library providing enum definitions for PostgreSQL AST nodes, primarily used in conjunction with [`pgsql-parser`](https://github.com/launchql/pgsql-parser). It offers a comprehensive and type-safe way to work with PostgreSQL enum values in query parsing and AST manipulation.
@@ -27,41 +27,23 @@ npm install @pgsql/enums
27
27
28
28
## Usage
29
29
30
-
`@pgsql/enums` provides TypeScript enum definitions for PostgreSQL Abstract Syntax Tree (AST) nodes. These enums are useful for constructing, analyzing, or manipulating ASTs in a type-safe manner with exact enum values.
31
-
32
-
Here are a few examples of how you can use these enums in your TypeScript projects:
33
-
34
-
### Using Enum Values
35
-
36
-
You can use the enums to work with specific PostgreSQL AST enum values:
30
+
Here's a simple example showing how to work with enums, converting between enum names and their numeric values:
Enums help ensure that you use correct PostgreSQL enum values:
35
+
// Get the numeric value of an enum
36
+
const tableValue =ObjectType.OBJECT_TABLE;
37
+
console.log(tableValue); // 41
55
38
56
-
```ts
57
-
import { CmdType, JoinType } from'@pgsql/enums';
58
-
59
-
const command = {
60
-
cmdType: CmdType.CMD_SELECT,
61
-
joinType: JoinType.JOIN_INNER
62
-
};
39
+
// Convert from value back to enum name
40
+
const enumName =ObjectType[41];
41
+
console.log(enumName); // "OBJECT_TABLE"
63
42
64
-
console.log(command);
43
+
// Use in comparisons
44
+
if (someNode.objectType===ObjectType.OBJECT_TABLE) {
45
+
console.log("This is a table object");
46
+
}
65
47
```
66
48
67
49
## Versions
@@ -89,4 +71,4 @@ Our latest is built with PostgreSQL 17 enum definitions.
89
71
90
72
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
91
73
92
-
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
74
+
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
`@pgsql/enums` is a TypeScript library providing enum definitions for PostgreSQL AST nodes, primarily used in conjunction with [`pgsql-parser`](https://github.com/launchql/pgsql-parser). It offers a comprehensive and type-safe way to work with PostgreSQL enum values in query parsing and AST manipulation.
@@ -27,41 +27,23 @@ npm install @pgsql/enums
27
27
28
28
## Usage
29
29
30
-
`@pgsql/enums` provides TypeScript enum definitions for PostgreSQL Abstract Syntax Tree (AST) nodes. These enums are useful for constructing, analyzing, or manipulating ASTs in a type-safe manner with exact enum values.
31
-
32
-
Here are a few examples of how you can use these enums in your TypeScript projects:
33
-
34
-
### Using Enum Values
35
-
36
-
You can use the enums to work with specific PostgreSQL AST enum values:
30
+
Here's a simple example showing how to work with enums, converting between enum names and their numeric values:
Enums help ensure that you use correct PostgreSQL enum values:
35
+
// Get the numeric value of an enum
36
+
const tableValue =ObjectType.OBJECT_TABLE;
37
+
console.log(tableValue); // 41
55
38
56
-
```ts
57
-
import { CmdType, JoinType } from'@pgsql/enums';
58
-
59
-
const command = {
60
-
cmdType: CmdType.CMD_SELECT,
61
-
joinType: JoinType.JOIN_INNER
62
-
};
39
+
// Convert from value back to enum name
40
+
const enumName =ObjectType[41];
41
+
console.log(enumName); // "OBJECT_TABLE"
63
42
64
-
console.log(command);
43
+
// Use in comparisons
44
+
if (someNode.objectType===ObjectType.OBJECT_TABLE) {
45
+
console.log("This is a table object");
46
+
}
65
47
```
66
48
67
49
## Versions
@@ -89,4 +71,4 @@ Our latest is built with PostgreSQL 17 enum definitions.
89
71
90
72
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
91
73
92
-
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
74
+
No developer or entity involved in creating Software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the Software code or Software CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
Copy file name to clipboardExpand all lines: enums/17/README.md
+12-30Lines changed: 12 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,41 +27,23 @@ npm install @pgsql/enums
27
27
28
28
## Usage
29
29
30
-
`@pgsql/enums` provides TypeScript enum definitions for PostgreSQL Abstract Syntax Tree (AST) nodes. These enums are useful for constructing, analyzing, or manipulating ASTs in a type-safe manner with exact enum values.
31
-
32
-
Here are a few examples of how you can use these enums in your TypeScript projects:
33
-
34
-
### Using Enum Values
35
-
36
-
You can use the enums to work with specific PostgreSQL AST enum values:
30
+
Here's a simple example showing how to work with enums, converting between enum names and their numeric values:
0 commit comments