@lowdefy/connection-knex 0.0.0-experimental-20250915134255 → 0.0.0-experimental-20251010122007
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.
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<TITLE>
|
|
2
|
+
KnexBuilder
|
|
3
|
+
</TITLE>
|
|
4
|
+
|
|
5
|
+
<DESCRIPTION>
|
|
6
|
+
|
|
7
|
+
### Properties
|
|
8
|
+
|
|
9
|
+
- `query: object[]`: **Required** - SQL query builder array. An array of objects, with a single key which is the name of the knex builder function. The value should be an array of arguments to pass to the builder function.
|
|
10
|
+
- `tableName: string | object`: The name of the table to query from.
|
|
11
|
+
|
|
12
|
+
</DESCRIPTION>
|
|
13
|
+
|
|
14
|
+
<CONNECTION>
|
|
15
|
+
Knex
|
|
16
|
+
</CONNECTION>
|
|
17
|
+
|
|
18
|
+
<SCHEMA>
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
export default {
|
|
22
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
23
|
+
title: 'Lowdefy Request Schema - KnexBuilder',
|
|
24
|
+
type: 'object',
|
|
25
|
+
required: ['query'],
|
|
26
|
+
properties: {
|
|
27
|
+
query: {
|
|
28
|
+
type: 'array',
|
|
29
|
+
description:
|
|
30
|
+
'SQL query builder array. An array of objects, with a single key which is the name of the knex builder function. The value should be an array of arguments to pass to the builder function.',
|
|
31
|
+
errorMessage: {
|
|
32
|
+
type: 'KnexBuilder request property "query" should be an array.',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
tableName: {
|
|
36
|
+
type: ['string', 'object'],
|
|
37
|
+
description: 'The name of the table to query from.',
|
|
38
|
+
errorMessage: {
|
|
39
|
+
type: 'KnexBuilder request property "tableName" should be a string or object',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
errorMessage: {
|
|
44
|
+
type: 'KnexBuilder request properties should be an object.',
|
|
45
|
+
required: {
|
|
46
|
+
query: 'KnexBuilder request should have required property "query".',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
</SCHEMA>
|
|
53
|
+
|
|
54
|
+
<EXAMPLES>
|
|
55
|
+
|
|
56
|
+
### Build a query
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
id: knexBuilder
|
|
60
|
+
type: KnexBuilder
|
|
61
|
+
connectionId: knex
|
|
62
|
+
payload:
|
|
63
|
+
name:
|
|
64
|
+
_state: name
|
|
65
|
+
properties:
|
|
66
|
+
query:
|
|
67
|
+
- select:
|
|
68
|
+
- '*'
|
|
69
|
+
- from:
|
|
70
|
+
- users
|
|
71
|
+
- where:
|
|
72
|
+
- name
|
|
73
|
+
- _payload: name
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Using `tableName`
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
id: knexBuilder
|
|
80
|
+
type: KnexBuilder
|
|
81
|
+
connectionId: knex
|
|
82
|
+
payload:
|
|
83
|
+
name:
|
|
84
|
+
_state: name
|
|
85
|
+
properties:
|
|
86
|
+
tableName: users
|
|
87
|
+
query:
|
|
88
|
+
- select:
|
|
89
|
+
- '*'
|
|
90
|
+
- where:
|
|
91
|
+
- name
|
|
92
|
+
- _payload: name
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Aliases
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
id: knexBuilder
|
|
99
|
+
type: KnexBuilder
|
|
100
|
+
connectionId: knex
|
|
101
|
+
properties:
|
|
102
|
+
tableName:
|
|
103
|
+
a: tableA
|
|
104
|
+
b: tableB
|
|
105
|
+
query:
|
|
106
|
+
- select:
|
|
107
|
+
- aField: 'a.field'
|
|
108
|
+
- bField: 'b.field'
|
|
109
|
+
- limit:
|
|
110
|
+
- 1
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
</EXAMPLES>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<TITLE>
|
|
2
|
+
KnexRaw
|
|
3
|
+
</TITLE>
|
|
4
|
+
|
|
5
|
+
<DESCRIPTION>
|
|
6
|
+
|
|
7
|
+
### Properties
|
|
8
|
+
|
|
9
|
+
- `query: string`: **Required** - SQL query string.
|
|
10
|
+
- `parameters: string | number | array | object`: SQL query parameters.
|
|
11
|
+
|
|
12
|
+
</DESCRIPTION>
|
|
13
|
+
|
|
14
|
+
<CONNECTION>
|
|
15
|
+
Knex
|
|
16
|
+
</CONNECTION>
|
|
17
|
+
|
|
18
|
+
<SCHEMA>
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
export default {
|
|
22
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
23
|
+
title: 'Lowdefy Request Schema - KnexRaw',
|
|
24
|
+
type: 'object',
|
|
25
|
+
required: ['query'],
|
|
26
|
+
properties: {
|
|
27
|
+
query: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'SQL query string.',
|
|
30
|
+
errorMessage: {
|
|
31
|
+
type: 'KnexRaw request property "query" should be a string.',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
parameters: {
|
|
35
|
+
type: ['string', 'number', 'array', 'object'],
|
|
36
|
+
description: 'SQL query parameters.',
|
|
37
|
+
errorMessage: {
|
|
38
|
+
type: 'KnexRaw request property "parameters" should be a string, number, array, or object.',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
errorMessage: {
|
|
43
|
+
type: 'KnexRaw request properties should be an object.',
|
|
44
|
+
required: {
|
|
45
|
+
query: 'KnexRaw request should have required property "query".',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
</SCHEMA>
|
|
52
|
+
|
|
53
|
+
<EXAMPLES>
|
|
54
|
+
|
|
55
|
+
### Simple raw query
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
id: knexRaw
|
|
59
|
+
type: KnexRaw
|
|
60
|
+
connectionId: knex
|
|
61
|
+
properties:
|
|
62
|
+
query: SELECT * FROM "my_table";
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Query with named parameters
|
|
66
|
+
|
|
67
|
+
```yaml
|
|
68
|
+
id: knexRaw
|
|
69
|
+
type: KnexRaw
|
|
70
|
+
connectionId: knex
|
|
71
|
+
payload:
|
|
72
|
+
selected_name:
|
|
73
|
+
_state: selected_name
|
|
74
|
+
properties:
|
|
75
|
+
query: select * from users where name = :name
|
|
76
|
+
parameters:
|
|
77
|
+
name:
|
|
78
|
+
_payload: selected_name
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Query with positional parameters
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
id: knexRaw
|
|
85
|
+
type: KnexRaw
|
|
86
|
+
connectionId: knex
|
|
87
|
+
payload:
|
|
88
|
+
selected_name:
|
|
89
|
+
_state: selected_name
|
|
90
|
+
properties:
|
|
91
|
+
query: select * from users where name = ?
|
|
92
|
+
parameters:
|
|
93
|
+
- _payload: selected_name
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Reference a `.sql` file
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
id: knexRaw
|
|
100
|
+
type: KnexRaw
|
|
101
|
+
connectionId: knex
|
|
102
|
+
properties:
|
|
103
|
+
query:
|
|
104
|
+
_ref: my_query.sql
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
</EXAMPLES>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<TITLE>
|
|
2
|
+
Knex
|
|
3
|
+
</TITLE>
|
|
4
|
+
|
|
5
|
+
<DESCRIPTION>
|
|
6
|
+
|
|
7
|
+
[`Knex.js`](http://knexjs.org) is a SQL query builder that can be used to connect to [PostgreSQL](/PostgreSQL), [MS SQL Server](/MSSQL), [MySQL](/MySQL), [MariaDB](/MariaDB), [SQLite](/SQLite), [Oracle](/Oracle), and [Amazon Redshift](/AmazonRedshift) databases.
|
|
8
|
+
|
|
9
|
+
The Knex connection can be used to execute raw SQL queries using the `KnexRaw` requests, or the Knex query builder can be used with the `KnexBuilder` request.
|
|
10
|
+
|
|
11
|
+
### Properties
|
|
12
|
+
|
|
13
|
+
- `client: enum`: __Required__ - The database client to use. One of:
|
|
14
|
+
- `mssql`
|
|
15
|
+
- `mysql`
|
|
16
|
+
- `oracledb`
|
|
17
|
+
- `postgres`
|
|
18
|
+
- `pg` (alias of `postgres`)
|
|
19
|
+
- `postgresql` (alias of `postgres`)
|
|
20
|
+
- `redshift`
|
|
21
|
+
- `sqlite3`
|
|
22
|
+
- `sqlite` (alias of `sqlite3`)
|
|
23
|
+
- `connection: object | string`: __Required__ - Connection string or object to pass to the database client. See the specific client documentation for more details.
|
|
24
|
+
- `searchPath: string`: Set PostgreSQL search path.
|
|
25
|
+
- `version: string`: Set database version.
|
|
26
|
+
- `useNullAsDefault: boolean`: If true, undefined keys are replaced with NULL instead of DEFAULT.
|
|
27
|
+
|
|
28
|
+
</DESCRIPTION>
|
|
29
|
+
|
|
30
|
+
<REQUESTS>
|
|
31
|
+
|
|
32
|
+
- KnexBuilder
|
|
33
|
+
- KnexRaw
|
|
34
|
+
|
|
35
|
+
</REQUESTS>
|
|
36
|
+
|
|
37
|
+
<SCHEMA>
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
export default {
|
|
41
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
42
|
+
title: 'Lowdefy Connection Schema - Knex',
|
|
43
|
+
type: 'object',
|
|
44
|
+
required: ['client', 'connection'],
|
|
45
|
+
properties: {
|
|
46
|
+
client: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'SQL query string.',
|
|
49
|
+
errorMessage: {
|
|
50
|
+
type: 'Knex connection property "client" should be a string.',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
connection: {
|
|
54
|
+
type: ['string', 'object'],
|
|
55
|
+
description: 'SQL query string.',
|
|
56
|
+
errorMessage: {
|
|
57
|
+
type: 'Knex connection property "connection" should be a string or object.',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
searchPath: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Set PostgreSQL search path.',
|
|
63
|
+
errorMessage: {
|
|
64
|
+
type: 'Knex connection property "searchPath" should be a string.',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
version: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'Set database version.',
|
|
70
|
+
errorMessage: {
|
|
71
|
+
type: 'Knex connection property "version" should be a string.',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
errorMessage: {
|
|
76
|
+
type: 'Knex connection properties should be an object.',
|
|
77
|
+
required: {
|
|
78
|
+
client: 'Knex connection should have required property "client".',
|
|
79
|
+
connection: 'Knex connection should have required property "connection".',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
</SCHEMA>
|
|
86
|
+
|
|
87
|
+
<EXAMPLES>
|
|
88
|
+
|
|
89
|
+
### MySQL with connection object
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
connections:
|
|
93
|
+
- id: mysql
|
|
94
|
+
type: Knex
|
|
95
|
+
properties:
|
|
96
|
+
client: mysql
|
|
97
|
+
connection:
|
|
98
|
+
host:
|
|
99
|
+
_secret: MYSQL_HOST
|
|
100
|
+
user:
|
|
101
|
+
_secret: MYSQL_USER
|
|
102
|
+
database:
|
|
103
|
+
_secret: MYSQL_DB
|
|
104
|
+
password:
|
|
105
|
+
_secret: MYSQL_PASSWORD
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Environment variables:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
LOWDEFY_SECRET_MYSQL_HOST = database.server.com
|
|
112
|
+
LOWDEFY_SECRET_MYSQL_DB = db
|
|
113
|
+
LOWDEFY_SECRET_MYSQL_USER = user
|
|
114
|
+
LOWDEFY_SECRET_MYSQL_PASSWORD = password
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### PostgreSQL with secret connection string
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
connections:
|
|
121
|
+
- id: postgres
|
|
122
|
+
type: Knex
|
|
123
|
+
properties:
|
|
124
|
+
client: postgres
|
|
125
|
+
connection:
|
|
126
|
+
_secret: PG_CONNECTION_STRING
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Environment variables:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
LOWDEFY_SECRET_PG_CONNECTION_STRING = postgresql://user:password@database.server.com:5432/db
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
</EXAMPLES>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/connection-knex",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-20251010122007",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dist/*"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@lowdefy/helpers": "0.0.0-experimental-
|
|
38
|
+
"@lowdefy/helpers": "0.0.0-experimental-20251010122007",
|
|
39
39
|
"knex": "2.5.1",
|
|
40
40
|
"mssql": "10.0.1",
|
|
41
41
|
"mysql": "2.18.1",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@jest/globals": "28.1.3",
|
|
47
|
-
"@lowdefy/ajv": "0.0.0-experimental-
|
|
47
|
+
"@lowdefy/ajv": "0.0.0-experimental-20251010122007",
|
|
48
48
|
"@swc/cli": "0.1.63",
|
|
49
49
|
"@swc/core": "1.3.99",
|
|
50
50
|
"@swc/jest": "0.2.29",
|