@kubun/db-node-sqlite 0.10.0 → 0.12.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 +41 -1
- package/package.json +11 -11
package/lib/index.js
CHANGED
|
@@ -1 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { AbstractSQLiteAdapter } from '@kubun/db-adapter';
|
|
3
|
+
import { SqliteDialect } from 'kysely';
|
|
4
|
+
function wrapStatement(stmt) {
|
|
5
|
+
return {
|
|
6
|
+
get reader () {
|
|
7
|
+
return stmt.columns().length > 0;
|
|
8
|
+
},
|
|
9
|
+
all (parameters) {
|
|
10
|
+
return stmt.all(...parameters);
|
|
11
|
+
},
|
|
12
|
+
run (parameters) {
|
|
13
|
+
return stmt.run(...parameters);
|
|
14
|
+
},
|
|
15
|
+
iterate (parameters) {
|
|
16
|
+
return stmt.iterate(...parameters);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function wrapDatabase(db) {
|
|
21
|
+
return {
|
|
22
|
+
close () {
|
|
23
|
+
db.close();
|
|
24
|
+
},
|
|
25
|
+
prepare (sql) {
|
|
26
|
+
return wrapStatement(db.prepare(sql));
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export class NodeSQLiteAdapter extends AbstractSQLiteAdapter {
|
|
31
|
+
#dialect;
|
|
32
|
+
constructor(params){
|
|
33
|
+
super();
|
|
34
|
+
this.#dialect = new SqliteDialect({
|
|
35
|
+
database: wrapDatabase(new DatabaseSync(params.database))
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
get dialect() {
|
|
39
|
+
return this.#dialect;
|
|
40
|
+
}
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/db-node-sqlite",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"license": "see LICENSE.md",
|
|
3
|
+
"version": "0.12.0",
|
|
5
4
|
"keywords": [],
|
|
5
|
+
"license": "see LICENSE.md",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"type": "module",
|
|
7
|
-
"main": "lib/index.js",
|
|
8
|
-
"types": "lib/index.d.ts",
|
|
9
8
|
"exports": {
|
|
10
9
|
".": "./lib/index.js"
|
|
11
10
|
},
|
|
11
|
+
"main": "lib/index.js",
|
|
12
|
+
"types": "lib/index.d.ts",
|
|
12
13
|
"files": [
|
|
13
14
|
"lib/*",
|
|
14
15
|
"LICENSE.md"
|
|
15
16
|
],
|
|
16
|
-
"sideEffects": false,
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"kysely": "^0.29.
|
|
19
|
-
"@kubun/db-adapter": "^0.
|
|
18
|
+
"kysely": "^0.29.4",
|
|
19
|
+
"@kubun/db-adapter": "^0.12.0"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
+
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|
|
22
23
|
"build:clean": "del lib",
|
|
23
|
-
"build:js": "swc src -d ./lib --config-file ../../swc.json --strip-leading-paths",
|
|
24
|
+
"build:js": "swc src -d ./lib --config-file ../../node_modules/@kigu/dev/swc.json --strip-leading-paths",
|
|
24
25
|
"build:types": "tsc --emitDeclarationOnly --skipLibCheck",
|
|
25
26
|
"build:types:ci": "tsc --emitDeclarationOnly --declarationMap false",
|
|
26
|
-
"
|
|
27
|
+
"test": "pnpm run test:types && pnpm run test:unit",
|
|
27
28
|
"test:types": "tsc --noEmit -p tsconfig.test.json",
|
|
28
|
-
"test:unit": "vitest run"
|
|
29
|
-
"test": "pnpm run test:types && pnpm run test:unit"
|
|
29
|
+
"test:unit": "vitest run"
|
|
30
30
|
}
|
|
31
31
|
}
|