@faasjs/knex 0.0.4-beta.9 → 0.0.5-beta.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/README.md +19 -15
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -6
- package/dist/index.mjs +14 -6
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -11,6 +11,10 @@ FaasJS's sql plugin, base on [Knex](https://knexjs.org/).
|
|
|
11
11
|
npm install @faasjs/knex
|
|
12
12
|
## Modules
|
|
13
13
|
|
|
14
|
+
### Namespaces
|
|
15
|
+
|
|
16
|
+
- [originKnex](modules/originKnex.md)
|
|
17
|
+
|
|
14
18
|
### Classes
|
|
15
19
|
|
|
16
20
|
- [Knex](classes/Knex.md)
|
|
@@ -44,7 +48,7 @@ FaasJS's sql plugin, base on [Knex](https://knexjs.org/).
|
|
|
44
48
|
|
|
45
49
|
### originKnex
|
|
46
50
|
|
|
47
|
-
▸ **originKnex
|
|
51
|
+
▸ **originKnex**\<`TRecord`, `TResult`\>(`config`): `Knex`\<`TRecord`, `TResult`\>
|
|
48
52
|
|
|
49
53
|
Origin [knex](https://knexjs.org/) instance.
|
|
50
54
|
|
|
@@ -59,17 +63,17 @@ Origin [knex](https://knexjs.org/) instance.
|
|
|
59
63
|
|
|
60
64
|
| Name | Type |
|
|
61
65
|
| :------ | :------ |
|
|
62
|
-
| `config` | `string` \| `Config
|
|
66
|
+
| `config` | `string` \| `Config`\<`any`\> |
|
|
63
67
|
|
|
64
68
|
#### Returns
|
|
65
69
|
|
|
66
|
-
`Knex
|
|
70
|
+
`Knex`\<`TRecord`, `TResult`\>
|
|
67
71
|
|
|
68
72
|
___
|
|
69
73
|
|
|
70
74
|
### query
|
|
71
75
|
|
|
72
|
-
▸ **query
|
|
76
|
+
▸ **query**\<`TName`\>(`table`): `OriginKnex.QueryBuilder`\<`OriginKnex.TableType`\<`TName`\>, \{ `_aliases`: {} ; `_base`: `OriginKnex.ResolveTableType`\<`OriginKnex.TableType`\<`TName`\>, ``"base"``\> ; `_hasSelection`: ``false`` ; `_intersectProps`: {} ; `_keys`: `never` ; `_single`: ``false`` ; `_unionProps`: `never` }[]\>
|
|
73
77
|
|
|
74
78
|
#### Type parameters
|
|
75
79
|
|
|
@@ -85,9 +89,9 @@ ___
|
|
|
85
89
|
|
|
86
90
|
#### Returns
|
|
87
91
|
|
|
88
|
-
`OriginKnex.QueryBuilder
|
|
92
|
+
`OriginKnex.QueryBuilder`\<`OriginKnex.TableType`\<`TName`\>, \{ `_aliases`: {} ; `_base`: `OriginKnex.ResolveTableType`\<`OriginKnex.TableType`\<`TName`\>, ``"base"``\> ; `_hasSelection`: ``false`` ; `_intersectProps`: {} ; `_keys`: `never` ; `_single`: ``false`` ; `_unionProps`: `never` }[]\>
|
|
89
93
|
|
|
90
|
-
▸ **query
|
|
94
|
+
▸ **query**\<`TName`, `TResult`\>(`table`): `OriginKnex.QueryBuilder`\<`TName`, `TResult`\>
|
|
91
95
|
|
|
92
96
|
#### Type parameters
|
|
93
97
|
|
|
@@ -104,13 +108,13 @@ ___
|
|
|
104
108
|
|
|
105
109
|
#### Returns
|
|
106
110
|
|
|
107
|
-
`OriginKnex.QueryBuilder
|
|
111
|
+
`OriginKnex.QueryBuilder`\<`TName`, `TResult`\>
|
|
108
112
|
|
|
109
113
|
___
|
|
110
114
|
|
|
111
115
|
### raw
|
|
112
116
|
|
|
113
|
-
▸ **raw
|
|
117
|
+
▸ **raw**\<`TResult`\>(`sql`, `bindings?`): `Promise`\<`TResult`\>
|
|
114
118
|
|
|
115
119
|
#### Type parameters
|
|
116
120
|
|
|
@@ -127,13 +131,13 @@ ___
|
|
|
127
131
|
|
|
128
132
|
#### Returns
|
|
129
133
|
|
|
130
|
-
`Promise
|
|
134
|
+
`Promise`\<`TResult`\>
|
|
131
135
|
|
|
132
136
|
___
|
|
133
137
|
|
|
134
138
|
### transaction
|
|
135
139
|
|
|
136
|
-
▸ **transaction
|
|
140
|
+
▸ **transaction**\<`TResult`\>(`scope`, `config?`, `options?`): `Promise`\<`TResult` \| `void`\>
|
|
137
141
|
|
|
138
142
|
#### Type parameters
|
|
139
143
|
|
|
@@ -145,20 +149,20 @@ ___
|
|
|
145
149
|
|
|
146
150
|
| Name | Type |
|
|
147
151
|
| :------ | :------ |
|
|
148
|
-
| `scope` | (`trx`: `Transaction
|
|
152
|
+
| `scope` | (`trx`: `Transaction`\<`any`, `any`\>) => `void` \| `Promise`\<`TResult`\> |
|
|
149
153
|
| `config?` | `TransactionConfig` |
|
|
150
154
|
| `options?` | `Object` |
|
|
151
|
-
| `options.trx?` | `Transaction
|
|
155
|
+
| `options.trx?` | `Transaction`\<`any`, `any`[]\> |
|
|
152
156
|
|
|
153
157
|
#### Returns
|
|
154
158
|
|
|
155
|
-
`Promise
|
|
159
|
+
`Promise`\<`TResult` \| `void`\>
|
|
156
160
|
|
|
157
161
|
___
|
|
158
162
|
|
|
159
163
|
### useKnex
|
|
160
164
|
|
|
161
|
-
▸ **useKnex**(`config?`): `UseifyPlugin
|
|
165
|
+
▸ **useKnex**(`config?`): `UseifyPlugin`\<[`Knex`](classes/Knex.md)\>
|
|
162
166
|
|
|
163
167
|
#### Parameters
|
|
164
168
|
|
|
@@ -168,4 +172,4 @@ ___
|
|
|
168
172
|
|
|
169
173
|
#### Returns
|
|
170
174
|
|
|
171
|
-
`UseifyPlugin
|
|
175
|
+
`UseifyPlugin`\<[`Knex`](classes/Knex.md)\>
|
package/dist/index.d.mts
CHANGED
|
@@ -46,4 +46,4 @@ declare function transaction<TResult = any>(scope: (trx: Knex$1.Transaction<any,
|
|
|
46
46
|
}): Promise<TResult | void>;
|
|
47
47
|
declare function raw<TResult = any>(sql: string, bindings?: Knex$1.RawBinding[] | Knex$1.ValueDict): Promise<TResult>;
|
|
48
48
|
|
|
49
|
-
export { Knex, KnexConfig, originKnex, query, raw, transaction, useKnex };
|
|
49
|
+
export { Knex, type KnexConfig, originKnex, query, raw, transaction, useKnex };
|
package/dist/index.d.ts
CHANGED
|
@@ -46,4 +46,4 @@ declare function transaction<TResult = any>(scope: (trx: Knex$1.Transaction<any,
|
|
|
46
46
|
}): Promise<TResult | void>;
|
|
47
47
|
declare function raw<TResult = any>(sql: string, bindings?: Knex$1.RawBinding[] | Knex$1.ValueDict): Promise<TResult>;
|
|
48
48
|
|
|
49
|
-
export { Knex, KnexConfig, originKnex, query, raw, transaction, useKnex };
|
|
49
|
+
export { Knex, type KnexConfig, originKnex, query, raw, transaction, useKnex };
|
package/dist/index.js
CHANGED
|
@@ -105,22 +105,30 @@ var Knex = class {
|
|
|
105
105
|
}
|
|
106
106
|
this.query = this.adapter;
|
|
107
107
|
this.query.on("query", ({ sql, __knexQueryUid, bindings }) => {
|
|
108
|
-
this.logger.time(`Knex${__knexQueryUid}`);
|
|
109
|
-
this.logger.debug(
|
|
108
|
+
this.logger.time(`Knex${this.name}${__knexQueryUid}`);
|
|
109
|
+
this.logger.debug(
|
|
110
|
+
"[%s][%s] query begin: %s %j",
|
|
111
|
+
this.name,
|
|
112
|
+
__knexQueryUid,
|
|
113
|
+
sql,
|
|
114
|
+
bindings
|
|
115
|
+
);
|
|
110
116
|
}).on("query-response", (response, { sql, __knexQueryUid, bindings }) => {
|
|
111
117
|
this.logger.timeEnd(
|
|
112
|
-
`Knex${__knexQueryUid}`,
|
|
113
|
-
"[%s] query done: %s %j %j",
|
|
118
|
+
`Knex${this.name}${__knexQueryUid}`,
|
|
119
|
+
"[%s][%s] query done: %s %j %j",
|
|
114
120
|
this.name,
|
|
121
|
+
__knexQueryUid,
|
|
115
122
|
sql,
|
|
116
123
|
bindings,
|
|
117
124
|
response
|
|
118
125
|
);
|
|
119
126
|
}).on("query-error", (_, { __knexQueryUid, sql, bindings }) => {
|
|
120
127
|
this.logger.timeEnd(
|
|
121
|
-
`Knex${__knexQueryUid}`,
|
|
122
|
-
"[%s] query failed: %s %j",
|
|
128
|
+
`Knex${this.name}${__knexQueryUid}`,
|
|
129
|
+
"[%s][%s] query failed: %s %j",
|
|
123
130
|
this.name,
|
|
131
|
+
__knexQueryUid,
|
|
124
132
|
sql,
|
|
125
133
|
bindings
|
|
126
134
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -99,22 +99,30 @@ var Knex = class {
|
|
|
99
99
|
}
|
|
100
100
|
this.query = this.adapter;
|
|
101
101
|
this.query.on("query", ({ sql, __knexQueryUid, bindings }) => {
|
|
102
|
-
this.logger.time(`Knex${__knexQueryUid}`);
|
|
103
|
-
this.logger.debug(
|
|
102
|
+
this.logger.time(`Knex${this.name}${__knexQueryUid}`);
|
|
103
|
+
this.logger.debug(
|
|
104
|
+
"[%s][%s] query begin: %s %j",
|
|
105
|
+
this.name,
|
|
106
|
+
__knexQueryUid,
|
|
107
|
+
sql,
|
|
108
|
+
bindings
|
|
109
|
+
);
|
|
104
110
|
}).on("query-response", (response, { sql, __knexQueryUid, bindings }) => {
|
|
105
111
|
this.logger.timeEnd(
|
|
106
|
-
`Knex${__knexQueryUid}`,
|
|
107
|
-
"[%s] query done: %s %j %j",
|
|
112
|
+
`Knex${this.name}${__knexQueryUid}`,
|
|
113
|
+
"[%s][%s] query done: %s %j %j",
|
|
108
114
|
this.name,
|
|
115
|
+
__knexQueryUid,
|
|
109
116
|
sql,
|
|
110
117
|
bindings,
|
|
111
118
|
response
|
|
112
119
|
);
|
|
113
120
|
}).on("query-error", (_, { __knexQueryUid, sql, bindings }) => {
|
|
114
121
|
this.logger.timeEnd(
|
|
115
|
-
`Knex${__knexQueryUid}`,
|
|
116
|
-
"[%s] query failed: %s %j",
|
|
122
|
+
`Knex${this.name}${__knexQueryUid}`,
|
|
123
|
+
"[%s][%s] query failed: %s %j",
|
|
117
124
|
this.name,
|
|
125
|
+
__knexQueryUid,
|
|
118
126
|
sql,
|
|
119
127
|
bindings
|
|
120
128
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/knex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@faasjs/deep_merge": "0.0.
|
|
25
|
-
"@faasjs/func": "0.0.
|
|
26
|
-
"@faasjs/logger": "0.0.
|
|
24
|
+
"@faasjs/deep_merge": "0.0.5-beta.2",
|
|
25
|
+
"@faasjs/func": "0.0.5-beta.2",
|
|
26
|
+
"@faasjs/logger": "0.0.5-beta.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"knex": "*"
|