@kubun/db-provider 0.9.0 → 0.11.0
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/lib/index.js +29 -1
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
import{KubunDB
|
|
1
|
+
import { KubunDB } from '@kubun/db';
|
|
2
|
+
import { NodeSQLiteAdapter } from '@kubun/db-node-sqlite';
|
|
3
|
+
import { PostgresAdapter } from '@kubun/db-postgres';
|
|
4
|
+
export function resolveAdapter(input) {
|
|
5
|
+
if (typeof input !== 'string') {
|
|
6
|
+
return input;
|
|
7
|
+
}
|
|
8
|
+
if (input === ':memory:') {
|
|
9
|
+
return new NodeSQLiteAdapter({
|
|
10
|
+
database: ':memory:'
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (input.startsWith('postgres://') || input.startsWith('postgresql://')) {
|
|
14
|
+
return new PostgresAdapter({
|
|
15
|
+
url: input
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return new NodeSQLiteAdapter({
|
|
19
|
+
database: input
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function resolveKubunDB(input) {
|
|
23
|
+
if (input instanceof KubunDB) {
|
|
24
|
+
return input;
|
|
25
|
+
}
|
|
26
|
+
return new KubunDB({
|
|
27
|
+
adapter: resolveAdapter(input)
|
|
28
|
+
});
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/db-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@kubun/db
|
|
19
|
-
"@kubun/db": "^0.
|
|
20
|
-
"@kubun/db-
|
|
21
|
-
"@kubun/db-adapter": "^0.
|
|
18
|
+
"@kubun/db": "^0.11.0",
|
|
19
|
+
"@kubun/db-postgres": "^0.11.0",
|
|
20
|
+
"@kubun/db-node-sqlite": "^0.11.0",
|
|
21
|
+
"@kubun/db-adapter": "^0.11.0"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build:clean": "del lib",
|
|
25
|
-
"build:js": "swc src -d ./lib --config-file ../../swc.json --strip-leading-paths",
|
|
25
|
+
"build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
|
|
26
26
|
"build:types": "tsc --emitDeclarationOnly --skipLibCheck",
|
|
27
27
|
"build:types:ci": "tsc --emitDeclarationOnly --declarationMap false",
|
|
28
28
|
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|