@faasjs/knex 0.0.2-beta.262 → 0.0.2-beta.302
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 +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.es.js +16 -6
- package/lib/index.js +16 -6
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Knex 插件
|
|
4
4
|
|
|
5
|
-
[](https://github.com/faasjs/faasjs/blob/
|
|
5
|
+
[](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/knex/LICENSE)
|
|
6
6
|
[](https://www.npmjs.com/package/@faasjs/knex)
|
|
7
7
|
[](https://www.npmjs.com/package/@faasjs/knex)
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Plugin, Next, DeployData, MountData, UseifyPlugin } from '@faasjs/func';
|
|
2
2
|
import { Logger } from '@faasjs/logger';
|
|
3
3
|
import { Knex as K } from 'knex';
|
|
4
|
-
export
|
|
4
|
+
export declare type KnexConfig = {
|
|
5
5
|
name?: string;
|
|
6
6
|
config?: K.Config;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
/**
|
|
9
9
|
* Knex 插件
|
|
10
10
|
*/
|
package/lib/index.es.js
CHANGED
|
@@ -54,8 +54,9 @@ class Knex {
|
|
|
54
54
|
key = key.replace(prefix, '').toLowerCase();
|
|
55
55
|
if (typeof this.config[key] === 'undefined')
|
|
56
56
|
if (key.startsWith('connection_')) {
|
|
57
|
-
if (!this.config.connection)
|
|
58
|
-
this.config.connection =
|
|
57
|
+
if (!this.config.connection) {
|
|
58
|
+
this.config.connection = Object.create(null);
|
|
59
|
+
}
|
|
59
60
|
this.config.connection[key.replace('connection_', '')] = value;
|
|
60
61
|
}
|
|
61
62
|
else
|
|
@@ -65,11 +66,20 @@ class Knex {
|
|
|
65
66
|
this.config = deepMerge(data.config.plugins[this.name].config, this.config);
|
|
66
67
|
this.adapter = knex(this.config);
|
|
67
68
|
if (this.config.client === 'pg') {
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
68
70
|
const pg = require('pg');
|
|
69
|
-
const intTypes = [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const intTypes = [
|
|
72
|
+
'INT2',
|
|
73
|
+
'INT4',
|
|
74
|
+
'INT8'
|
|
75
|
+
];
|
|
76
|
+
intTypes.forEach(t => pg.types.setTypeParser(pg.types.builtins[t], (v) => parseInt(v)));
|
|
77
|
+
const floatTypes = [
|
|
78
|
+
'FLOAT4',
|
|
79
|
+
'FLOAT8',
|
|
80
|
+
'NUMERIC'
|
|
81
|
+
];
|
|
82
|
+
floatTypes.forEach(t => pg.types.setTypeParser(pg.types.builtins[t], (v) => parseFloat(v)));
|
|
73
83
|
}
|
|
74
84
|
this.adapter
|
|
75
85
|
.on('query', ({ sql, __knexQueryUid, bindings }) => {
|
package/lib/index.js
CHANGED
|
@@ -62,8 +62,9 @@ class Knex {
|
|
|
62
62
|
key = key.replace(prefix, '').toLowerCase();
|
|
63
63
|
if (typeof this.config[key] === 'undefined')
|
|
64
64
|
if (key.startsWith('connection_')) {
|
|
65
|
-
if (!this.config.connection)
|
|
66
|
-
this.config.connection =
|
|
65
|
+
if (!this.config.connection) {
|
|
66
|
+
this.config.connection = Object.create(null);
|
|
67
|
+
}
|
|
67
68
|
this.config.connection[key.replace('connection_', '')] = value;
|
|
68
69
|
}
|
|
69
70
|
else
|
|
@@ -73,11 +74,20 @@ class Knex {
|
|
|
73
74
|
this.config = deep_merge.deepMerge(data.config.plugins[this.name].config, this.config);
|
|
74
75
|
this.adapter = knex__default["default"](this.config);
|
|
75
76
|
if (this.config.client === 'pg') {
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
76
78
|
const pg = require('pg');
|
|
77
|
-
const intTypes = [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const intTypes = [
|
|
80
|
+
'INT2',
|
|
81
|
+
'INT4',
|
|
82
|
+
'INT8'
|
|
83
|
+
];
|
|
84
|
+
intTypes.forEach(t => pg.types.setTypeParser(pg.types.builtins[t], (v) => parseInt(v)));
|
|
85
|
+
const floatTypes = [
|
|
86
|
+
'FLOAT4',
|
|
87
|
+
'FLOAT8',
|
|
88
|
+
'NUMERIC'
|
|
89
|
+
];
|
|
90
|
+
floatTypes.forEach(t => pg.types.setTypeParser(pg.types.builtins[t], (v) => parseFloat(v)));
|
|
81
91
|
}
|
|
82
92
|
this.adapter
|
|
83
93
|
.on('query', ({ sql, __knexQueryUid, bindings }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/knex",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.302",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"url": "git+https://github.com/faasjs/faasjs.git",
|
|
12
12
|
"directory": "packages/knex"
|
|
13
13
|
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/faasjs/faasjs/issues"
|
|
16
|
+
},
|
|
17
|
+
"funding": "https://github.com/sponsors/faasjs",
|
|
14
18
|
"scripts": {
|
|
15
19
|
"prepack": "rm -rf ./lib && rollup -c && mv lib/*/src/* lib/"
|
|
16
20
|
},
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
"knex": "*"
|
|
24
28
|
},
|
|
25
29
|
"devDependencies": {
|
|
26
|
-
"@faasjs/func": "^0.0.2-beta.
|
|
30
|
+
"@faasjs/func": "^0.0.2-beta.302",
|
|
27
31
|
"@types/debug": "*",
|
|
28
32
|
"@types/jest": "*",
|
|
29
33
|
"@types/mysql": "*",
|
|
@@ -37,5 +41,8 @@
|
|
|
37
41
|
"sqlite3": "*",
|
|
38
42
|
"typescript": "*"
|
|
39
43
|
},
|
|
40
|
-
"
|
|
44
|
+
"engines": {
|
|
45
|
+
"npm": ">=8.0.0"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "b53fb35a91369afd0185fb555d98e5c9d90b54bd"
|
|
41
48
|
}
|