baja-lite 1.6.6 → 1.7.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/boot-remote.js +8 -2
- package/boot.js +9 -3
- package/package.json +1 -1
- package/sql.d.ts +48 -3
- package/sql.js +183 -150
- package/sqlite.js +18 -20
package/sqlite.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { decode, encode } from "@msgpack/msgpack";
|
|
2
2
|
import Sqlstring from 'sqlstring';
|
|
3
3
|
import { snowflake } from './snowflake.js';
|
|
4
|
-
import {
|
|
4
|
+
import { _LoggerService, extensionCodec } from './sql.js';
|
|
5
5
|
export class SqliteRemoteClass {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.dbList = {};
|
|
8
8
|
}
|
|
9
9
|
async execute(inData) {
|
|
10
10
|
const [dbName, sql, params] = decode(inData);
|
|
11
|
-
|
|
11
|
+
globalThis[_LoggerService].debug?.(sql, params ?? '');
|
|
12
12
|
try {
|
|
13
13
|
if (!sql) {
|
|
14
14
|
return encode({ affectedRows: 0, insertId: 0n }, { extensionCodec });
|
|
15
15
|
}
|
|
16
16
|
;
|
|
17
17
|
if (this.trace) {
|
|
18
|
-
|
|
18
|
+
globalThis[_LoggerService].verbose?.(Sqlstring.format(sql, params));
|
|
19
19
|
}
|
|
20
20
|
const result = this.dbList[dbName].prepare(sql).run(params ?? {});
|
|
21
21
|
if (this.trace) {
|
|
22
|
-
|
|
22
|
+
globalThis[_LoggerService].verbose?.(result);
|
|
23
23
|
}
|
|
24
24
|
const { changes, lastInsertRowid } = result;
|
|
25
25
|
return encode({ affectedRows: changes, insertId: lastInsertRowid ? BigInt(lastInsertRowid) : 0n }, { extensionCodec });
|
|
26
26
|
}
|
|
27
27
|
catch (error) {
|
|
28
|
-
|
|
28
|
+
globalThis[_LoggerService].error(`
|
|
29
29
|
error: ${error},
|
|
30
30
|
sql: ${sql},
|
|
31
31
|
params: ${params}
|
|
@@ -35,20 +35,18 @@ export class SqliteRemoteClass {
|
|
|
35
35
|
}
|
|
36
36
|
async pluck(inData) {
|
|
37
37
|
const [dbName, sql, params] = decode(inData);
|
|
38
|
-
|
|
38
|
+
globalThis[_LoggerService].debug?.(sql, params ?? '');
|
|
39
39
|
try {
|
|
40
|
-
|
|
40
|
+
globalThis[_LoggerService].debug?.(sql, params ?? '');
|
|
41
41
|
if (!sql) {
|
|
42
42
|
return encode(null);
|
|
43
43
|
}
|
|
44
44
|
;
|
|
45
|
-
|
|
46
|
-
logger.trace(Sqlstring.format(sql, params));
|
|
47
|
-
}
|
|
45
|
+
globalThis[_LoggerService].verbose?.(Sqlstring.format(sql, params));
|
|
48
46
|
return encode(this.dbList[dbName].prepare(sql).pluck().get(params ?? {}), { extensionCodec });
|
|
49
47
|
}
|
|
50
48
|
catch (error) {
|
|
51
|
-
|
|
49
|
+
globalThis[_LoggerService].error(`
|
|
52
50
|
error: ${error},
|
|
53
51
|
sql: ${sql},
|
|
54
52
|
params: ${params}
|
|
@@ -58,15 +56,15 @@ export class SqliteRemoteClass {
|
|
|
58
56
|
}
|
|
59
57
|
async get(inData) {
|
|
60
58
|
const [dbName, sql, params] = decode(inData);
|
|
61
|
-
|
|
59
|
+
globalThis[_LoggerService].debug?.(sql, params ?? '');
|
|
62
60
|
try {
|
|
63
61
|
if (this.trace) {
|
|
64
|
-
|
|
62
|
+
globalThis[_LoggerService].verbose?.(Sqlstring.format(sql, params));
|
|
65
63
|
}
|
|
66
64
|
return encode(this.dbList[dbName].prepare(sql).get(params ?? {}), { extensionCodec });
|
|
67
65
|
}
|
|
68
66
|
catch (error) {
|
|
69
|
-
|
|
67
|
+
globalThis[_LoggerService].error(`
|
|
70
68
|
error: ${error},
|
|
71
69
|
sql: ${sql},
|
|
72
70
|
params: ${params}
|
|
@@ -76,19 +74,19 @@ export class SqliteRemoteClass {
|
|
|
76
74
|
}
|
|
77
75
|
async raw(inData) {
|
|
78
76
|
const [dbName, sql, params] = decode(inData);
|
|
79
|
-
|
|
77
|
+
globalThis[_LoggerService].debug?.(sql, params ?? '');
|
|
80
78
|
try {
|
|
81
79
|
if (!sql) {
|
|
82
80
|
return encode([]);
|
|
83
81
|
}
|
|
84
82
|
;
|
|
85
83
|
if (this.trace) {
|
|
86
|
-
|
|
84
|
+
globalThis[_LoggerService].verbose?.(Sqlstring.format(sql, params));
|
|
87
85
|
}
|
|
88
86
|
return encode(this.dbList[dbName].prepare(sql).raw().all(params ?? {}), { extensionCodec });
|
|
89
87
|
}
|
|
90
88
|
catch (error) {
|
|
91
|
-
|
|
89
|
+
globalThis[_LoggerService].error(`
|
|
92
90
|
error: ${error},
|
|
93
91
|
sql: ${sql},
|
|
94
92
|
params: ${params}
|
|
@@ -98,19 +96,19 @@ export class SqliteRemoteClass {
|
|
|
98
96
|
}
|
|
99
97
|
async query(inData) {
|
|
100
98
|
const [dbName, sql, params] = decode(inData);
|
|
101
|
-
|
|
99
|
+
globalThis[_LoggerService].debug?.(sql, params ?? '');
|
|
102
100
|
try {
|
|
103
101
|
if (!sql) {
|
|
104
102
|
encode([]);
|
|
105
103
|
}
|
|
106
104
|
;
|
|
107
105
|
if (this.trace) {
|
|
108
|
-
|
|
106
|
+
globalThis[_LoggerService].verbose?.(Sqlstring.format(sql, params));
|
|
109
107
|
}
|
|
110
108
|
return encode(this.dbList[dbName].prepare(sql).all(params ?? {}), { extensionCodec });
|
|
111
109
|
}
|
|
112
110
|
catch (error) {
|
|
113
|
-
|
|
111
|
+
globalThis[_LoggerService].error(`
|
|
114
112
|
error: ${error},
|
|
115
113
|
sql: ${sql},
|
|
116
114
|
params: ${params}
|