@onurege3467/zerohelper 9.0.0 → 9.2.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/README.md +152 -254
- package/dist/bin/zero.d.ts +2 -0
- package/dist/bin/zero.js +141 -0
- package/dist/database/IDatabase.d.ts +25 -31
- package/dist/database/IDatabase.js +38 -0
- package/dist/database/cacheWrapper.d.ts +5 -2
- package/dist/database/cacheWrapper.js +36 -50
- package/dist/database/index.d.ts +3 -2
- package/dist/database/index.js +13 -9
- package/dist/database/json.d.ts +4 -4
- package/dist/database/json.js +85 -87
- package/dist/database/mongodb.d.ts +12 -12
- package/dist/database/mongodb.js +49 -82
- package/dist/database/mysql.d.ts +7 -9
- package/dist/database/mysql.js +149 -270
- package/dist/database/pg.d.ts +12 -14
- package/dist/database/pg.js +113 -222
- package/dist/database/redis.d.ts +5 -3
- package/dist/database/redis.js +81 -107
- package/dist/database/seeder.d.ts +20 -0
- package/dist/database/seeder.js +37 -0
- package/dist/database/sqlite.d.ts +12 -15
- package/dist/database/sqlite.js +108 -223
- package/dist/database/telemetry.d.ts +35 -0
- package/dist/database/telemetry.js +41 -0
- package/dist/database/toon.d.ts +32 -0
- package/dist/database/toon.js +209 -0
- package/dist/database/types.d.ts +28 -34
- package/dist/database/zpack.d.ts +10 -4
- package/dist/database/zpack.js +151 -71
- package/dist/functions/index.d.ts +16 -0
- package/dist/functions/index.js +49 -3
- package/dist/functions/security.d.ts +15 -0
- package/dist/functions/security.js +46 -0
- package/dist/functions/toon.d.ts +7 -0
- package/dist/functions/toon.js +118 -0
- package/dist/functions/worker.d.ts +5 -0
- package/dist/functions/worker.js +35 -0
- package/dist/test_v91_advanced.d.ts +1 -0
- package/dist/test_v91_advanced.js +48 -0
- package/dist/test_v91_basics.d.ts +1 -0
- package/dist/test_v91_basics.js +54 -0
- package/dist/test_v91_performance.d.ts +1 -0
- package/dist/test_v91_performance.js +54 -0
- package/package.json +16 -3
package/dist/database/sqlite.js
CHANGED
|
@@ -11,262 +11,147 @@ const path_1 = __importDefault(require("path"));
|
|
|
11
11
|
class SQLiteDatabase extends IDatabase_1.IDatabase {
|
|
12
12
|
constructor(config) {
|
|
13
13
|
super();
|
|
14
|
-
if (!config || !config.
|
|
15
|
-
throw new Error('SQLite
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!fs_1.default.existsSync(dir)) {
|
|
14
|
+
if (!config || !config.path)
|
|
15
|
+
throw new Error('SQLite "path" gereklidir.');
|
|
16
|
+
const dir = path_1.default.dirname(config.path);
|
|
17
|
+
if (!fs_1.default.existsSync(dir))
|
|
19
18
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
20
|
-
|
|
21
|
-
this.db = new sqlite3_1.default.Database(config.filename, (err) => {
|
|
22
|
-
if (err) {
|
|
23
|
-
console.error("SQLite connection error:", err.message);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
_detectColumnType(value) {
|
|
28
|
-
if (value === null || value === undefined)
|
|
29
|
-
return 'TEXT';
|
|
30
|
-
if (typeof value === 'boolean')
|
|
31
|
-
return 'BOOLEAN';
|
|
32
|
-
if (typeof value === 'number')
|
|
33
|
-
return Number.isInteger(value) ? 'INTEGER' : 'REAL';
|
|
34
|
-
if (value instanceof Date)
|
|
35
|
-
return 'DATETIME';
|
|
36
|
-
if (typeof value === 'string') {
|
|
37
|
-
if (value.trim() === '')
|
|
38
|
-
return 'TEXT';
|
|
39
|
-
if (/^-?\d+$/.test(value.trim()))
|
|
40
|
-
return 'INTEGER';
|
|
41
|
-
if (/^-?\d+\.\d+$/.test(value.trim()))
|
|
42
|
-
return 'REAL';
|
|
43
|
-
const lowerValue = value.toLowerCase().trim();
|
|
44
|
-
if (lowerValue === 'true' || lowerValue === 'false')
|
|
45
|
-
return 'BOOLEAN';
|
|
46
|
-
if (value.match(/^\d{4}-\d{2}-\d{2}/))
|
|
47
|
-
return 'DATETIME';
|
|
48
|
-
}
|
|
49
|
-
return 'TEXT';
|
|
19
|
+
this.db = new sqlite3_1.default.Database(config.path);
|
|
50
20
|
}
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
return
|
|
21
|
+
async _execute(op, table, fn) {
|
|
22
|
+
const start = Date.now();
|
|
23
|
+
const res = await fn();
|
|
24
|
+
this.recordMetric(op, table, Date.now() - start);
|
|
25
|
+
return res;
|
|
56
26
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
`);
|
|
60
|
-
const existingNames = columnsInfo.map(col => col.name);
|
|
61
|
-
for (const key of Object.keys(data)) {
|
|
62
|
-
if (!existingNames.includes(key)) {
|
|
63
|
-
const columnType = this._detectColumnType(data[key]);
|
|
64
|
-
await this.query(`ALTER TABLE
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
query(sql, params = []) {
|
|
27
|
+
;
|
|
28
|
+
async query(sql, params = []) {
|
|
69
29
|
return new Promise((resolve, reject) => {
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
this.db.all(sql, params, (err, rows) =>
|
|
73
|
-
if (err)
|
|
74
|
-
reject(err);
|
|
75
|
-
else
|
|
76
|
-
resolve(rows);
|
|
77
|
-
});
|
|
30
|
+
const s = sql.trim().toUpperCase();
|
|
31
|
+
if (s.startsWith('SELECT') || s.startsWith('PRAGMA')) {
|
|
32
|
+
this.db.all(sql, params, (err, rows) => err ? reject(err) : resolve(rows));
|
|
78
33
|
}
|
|
79
34
|
else {
|
|
80
|
-
this.db.run(sql, params, function (err) {
|
|
81
|
-
if (err)
|
|
82
|
-
reject(err);
|
|
83
|
-
else
|
|
84
|
-
resolve({ changes: this.changes, lastInsertRowid: this.lastID });
|
|
85
|
-
});
|
|
35
|
+
this.db.run(sql, params, function (err) { err ? reject(err) : resolve({ changes: this.changes, lastID: this.lastID }); });
|
|
86
36
|
}
|
|
87
37
|
});
|
|
88
38
|
}
|
|
89
39
|
async ensureTable(table, data = {}) {
|
|
90
40
|
try {
|
|
91
|
-
await this.query(`SELECT 1 FROM
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
99
|
-
const columnsPart = columnDefinitions.length > 0 ? ', ' + columnDefinitions.join(", ") : '';
|
|
100
|
-
const createTableSQL = `CREATE TABLE
|
|
101
|
-
await this.query(createTableSQL);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
throw error;
|
|
41
|
+
await this.query(`SELECT 1 FROM "${table}" LIMIT 1`);
|
|
42
|
+
const info = await this.query(`PRAGMA table_info("${table}")`);
|
|
43
|
+
const names = info.map(c => c.name);
|
|
44
|
+
for (const key of Object.keys(data)) {
|
|
45
|
+
if (key !== '_id' && !names.includes(key)) {
|
|
46
|
+
await this.query(`ALTER TABLE "${table}" ADD COLUMN "${key}" TEXT`);
|
|
47
|
+
}
|
|
105
48
|
}
|
|
106
49
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return value.toISOString();
|
|
111
|
-
if (Array.isArray(value) || (typeof value === 'object' && value !== null))
|
|
112
|
-
return JSON.stringify(value);
|
|
113
|
-
return value;
|
|
114
|
-
}
|
|
115
|
-
_deserializeValue(value) {
|
|
116
|
-
if (typeof value === 'string' && (value.startsWith('[') || value.startsWith('{'))) {
|
|
117
|
-
try {
|
|
118
|
-
const parsed = JSON.parse(value);
|
|
119
|
-
if (typeof parsed === 'object' && parsed !== null)
|
|
120
|
-
return parsed;
|
|
121
|
-
}
|
|
122
|
-
catch (e) { }
|
|
50
|
+
catch {
|
|
51
|
+
const defs = Object.keys(data).map(k => `"${k}" TEXT`);
|
|
52
|
+
await this.query(`CREATE TABLE "${table}" (_id INTEGER PRIMARY KEY AUTOINCREMENT ${defs.length ? ', ' + defs.join(',') : ''})`);
|
|
123
53
|
}
|
|
124
|
-
return value;
|
|
125
54
|
}
|
|
126
55
|
async insert(table, data) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
56
|
+
await this.runHooks('beforeInsert', table, data);
|
|
57
|
+
return this._execute('insert', table, async () => {
|
|
58
|
+
await this.ensureTable(table, data);
|
|
59
|
+
const keys = Object.keys(data);
|
|
60
|
+
const sql = `INSERT INTO "${table}" (${keys.map(k => `"${k}"`).join(',')}) VALUES (${keys.map(() => '?').join(',')})`;
|
|
61
|
+
const res = await this.query(sql, Object.values(data).map(v => typeof v === 'object' ? JSON.stringify(v) : v));
|
|
62
|
+
const finalData = { _id: res.lastID, ...data };
|
|
63
|
+
await this.runHooks('afterInsert', table, finalData);
|
|
64
|
+
return res.lastID;
|
|
65
|
+
});
|
|
136
66
|
}
|
|
137
67
|
async update(table, data, where) {
|
|
138
|
-
await this.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
68
|
+
await this.runHooks('beforeUpdate', table, { data, where });
|
|
69
|
+
return this._execute('update', table, async () => {
|
|
70
|
+
await this.ensureTable(table, { ...data, ...where });
|
|
71
|
+
const set = Object.keys(data).map(k => `"${k}" = ?`).join(',');
|
|
72
|
+
const { whereClause, values: whereValues } = this._buildWhereClause(where);
|
|
73
|
+
const sql = `UPDATE "${table}" SET ${set} ${whereClause}`;
|
|
74
|
+
const res = await this.query(sql, [...Object.values(data).map(v => typeof v === 'object' ? JSON.stringify(v) : v), ...whereValues]);
|
|
75
|
+
return res.changes;
|
|
76
|
+
});
|
|
145
77
|
}
|
|
146
78
|
async delete(table, where) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
79
|
+
await this.runHooks('beforeDelete', table, where);
|
|
80
|
+
return this._execute('delete', table, async () => {
|
|
81
|
+
await this.ensureTable(table, where);
|
|
82
|
+
const { whereClause, values } = this._buildWhereClause(where);
|
|
83
|
+
const sql = `DELETE FROM "${table}" ${whereClause}`;
|
|
84
|
+
const res = await this.query(sql, values);
|
|
85
|
+
return res.changes;
|
|
86
|
+
});
|
|
155
87
|
}
|
|
156
88
|
async select(table, where = null) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
return newRow;
|
|
89
|
+
return this._execute('select', table, async () => {
|
|
90
|
+
await this.ensureTable(table, where || {});
|
|
91
|
+
const { whereClause, values } = this._buildWhereClause(where);
|
|
92
|
+
const rows = await this.query(`SELECT * FROM "${table}" ${whereClause}`, values);
|
|
93
|
+
return rows.map((r) => {
|
|
94
|
+
const nr = {};
|
|
95
|
+
for (const k in r) {
|
|
96
|
+
try {
|
|
97
|
+
nr[k] = JSON.parse(r[k]);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
nr[k] = r[k];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return nr;
|
|
104
|
+
});
|
|
175
105
|
});
|
|
176
106
|
}
|
|
177
|
-
async set(table, data, where) {
|
|
178
|
-
const existing = await this.select(table, where);
|
|
179
|
-
if (existing.length === 0) {
|
|
180
|
-
return await this.insert(table, { ...where, ...data });
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
return await this.update(table, data, where);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
107
|
async selectOne(table, where = null) {
|
|
187
|
-
const
|
|
188
|
-
return
|
|
108
|
+
const res = await this.select(table, where);
|
|
109
|
+
return res[0] || null;
|
|
110
|
+
}
|
|
111
|
+
async set(table, data, where) {
|
|
112
|
+
const ex = await this.selectOne(table, where);
|
|
113
|
+
return ex ? this.update(table, data, where) : this.insert(table, { ...where, ...data });
|
|
189
114
|
}
|
|
190
115
|
async bulkInsert(table, dataArray) {
|
|
191
|
-
if (!
|
|
116
|
+
if (!dataArray.length)
|
|
192
117
|
return 0;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
dataArray.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const sql = `INSERT INTO
|
|
206
|
-
return new Promise((resolve, reject) => {
|
|
207
|
-
this.db.serialize(() => {
|
|
208
|
-
this.db.run("BEGIN TRANSACTION;");
|
|
209
|
-
let completed = 0;
|
|
210
|
-
let hasError = false;
|
|
211
|
-
const stmt = this.db.prepare(sql);
|
|
212
|
-
for (const item of dataArray) {
|
|
213
|
-
if (hasError)
|
|
214
|
-
break;
|
|
215
|
-
stmt.run(keys.map(k => this._serializeValue(item[k])), (err) => {
|
|
216
|
-
if (err && !hasError) {
|
|
217
|
-
hasError = true;
|
|
218
|
-
this.db.run("ROLLBACK;");
|
|
219
|
-
reject(err);
|
|
220
|
-
}
|
|
221
|
-
completed++;
|
|
222
|
-
if (completed === dataArray.length && !hasError) {
|
|
223
|
-
this.db.run("COMMIT;", (err) => {
|
|
224
|
-
if (err)
|
|
225
|
-
reject(err);
|
|
226
|
-
else {
|
|
227
|
-
stmt.finalize();
|
|
228
|
-
resolve(dataArray.length);
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
});
|
|
118
|
+
for (const d of dataArray)
|
|
119
|
+
await this.insert(table, d);
|
|
120
|
+
return dataArray.length;
|
|
121
|
+
}
|
|
122
|
+
async increment(table, incs, where) {
|
|
123
|
+
return this._execute('increment', table, async () => {
|
|
124
|
+
await this.ensureTable(table, where);
|
|
125
|
+
const set = Object.keys(incs).map(f => `"${f}" = CAST("${f}" AS NUMERIC) + ?`);
|
|
126
|
+
const { whereClause, values } = this._buildWhereClause(where);
|
|
127
|
+
const sql = `UPDATE "${table}" SET ${set} ${whereClause}`;
|
|
128
|
+
const res = await this.query(sql, [...Object.values(incs), ...values]);
|
|
129
|
+
return res.changes;
|
|
235
130
|
});
|
|
236
131
|
}
|
|
237
|
-
async
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const result = await this.query(sql, [...incrementValues, ...whereValues]);
|
|
243
|
-
return result.changes;
|
|
132
|
+
async decrement(table, decs, where) {
|
|
133
|
+
const incs = {};
|
|
134
|
+
for (const k in decs)
|
|
135
|
+
incs[k] = -decs[k];
|
|
136
|
+
return this.increment(table, incs, where);
|
|
244
137
|
}
|
|
245
|
-
async
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
const result = await this.query(sql, [...decrementValues, ...whereValues]);
|
|
251
|
-
return result.changes;
|
|
138
|
+
async close() { return new Promise((resolve, reject) => this.db.close(err => err ? reject(err) : resolve())); }
|
|
139
|
+
_serializeValue(v) {
|
|
140
|
+
if (v instanceof Date)
|
|
141
|
+
return v.toISOString().slice(0, 19).replace('T', ' ');
|
|
142
|
+
return (typeof v === 'object' && v !== null) ? JSON.stringify(v) : v;
|
|
252
143
|
}
|
|
253
|
-
_buildWhereClause(where
|
|
254
|
-
|
|
255
|
-
if (conditions.length === 0)
|
|
144
|
+
_buildWhereClause(where) {
|
|
145
|
+
if (!where)
|
|
256
146
|
return { whereClause: '', values: [] };
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
reject(err);
|
|
266
|
-
else
|
|
267
|
-
resolve();
|
|
268
|
-
});
|
|
269
|
-
});
|
|
147
|
+
const safeWhere = where;
|
|
148
|
+
const keys = Object.keys(safeWhere);
|
|
149
|
+
if (!keys.length)
|
|
150
|
+
return { whereClause: '', values: [] };
|
|
151
|
+
return {
|
|
152
|
+
whereClause: 'WHERE ' + keys.map(k => `"${k}" = ?`).join(' AND '),
|
|
153
|
+
values: keys.map(k => this._serializeValue(safeWhere[k]))
|
|
154
|
+
};
|
|
270
155
|
}
|
|
271
156
|
}
|
|
272
157
|
exports.SQLiteDatabase = SQLiteDatabase;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface DatabaseMetrics {
|
|
2
|
+
operation: string;
|
|
3
|
+
table: string;
|
|
4
|
+
duration: number;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CacheMetrics {
|
|
8
|
+
hits: number;
|
|
9
|
+
misses: number;
|
|
10
|
+
keys: number;
|
|
11
|
+
}
|
|
12
|
+
declare class TelemetrySystem {
|
|
13
|
+
private dbMetrics;
|
|
14
|
+
private cacheStats;
|
|
15
|
+
private maxLogs;
|
|
16
|
+
recordDb(metric: DatabaseMetrics): void;
|
|
17
|
+
recordCacheHit(): void;
|
|
18
|
+
recordCacheMiss(): void;
|
|
19
|
+
getMetrics(): {
|
|
20
|
+
database: {
|
|
21
|
+
totalOperations: number;
|
|
22
|
+
averageDuration: string;
|
|
23
|
+
slowestOperations: DatabaseMetrics[];
|
|
24
|
+
recentLogs: DatabaseMetrics[];
|
|
25
|
+
};
|
|
26
|
+
cache: {
|
|
27
|
+
ratio: string;
|
|
28
|
+
hits: number;
|
|
29
|
+
misses: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
clear(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare const telemetry: TelemetrySystem;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// database/telemetry.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.telemetry = void 0;
|
|
5
|
+
class TelemetrySystem {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.dbMetrics = [];
|
|
8
|
+
this.cacheStats = { hits: 0, misses: 0 };
|
|
9
|
+
this.maxLogs = 1000;
|
|
10
|
+
}
|
|
11
|
+
recordDb(metric) {
|
|
12
|
+
this.dbMetrics.push(metric);
|
|
13
|
+
if (this.dbMetrics.length > this.maxLogs)
|
|
14
|
+
this.dbMetrics.shift();
|
|
15
|
+
}
|
|
16
|
+
recordCacheHit() { this.cacheStats.hits++; }
|
|
17
|
+
recordCacheMiss() { this.cacheStats.misses++; }
|
|
18
|
+
getMetrics() {
|
|
19
|
+
const totalOps = this.dbMetrics.length;
|
|
20
|
+
const avgDuration = totalOps > 0
|
|
21
|
+
? this.dbMetrics.reduce((s, m) => s + m.duration, 0) / totalOps
|
|
22
|
+
: 0;
|
|
23
|
+
return {
|
|
24
|
+
database: {
|
|
25
|
+
totalOperations: totalOps,
|
|
26
|
+
averageDuration: avgDuration.toFixed(2) + 'ms',
|
|
27
|
+
slowestOperations: [...this.dbMetrics].sort((a, b) => b.duration - a.duration).slice(0, 5),
|
|
28
|
+
recentLogs: this.dbMetrics.slice(-10)
|
|
29
|
+
},
|
|
30
|
+
cache: {
|
|
31
|
+
...this.cacheStats,
|
|
32
|
+
ratio: (this.cacheStats.hits / (this.cacheStats.hits + this.cacheStats.misses || 1) * 100).toFixed(2) + '%'
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
clear() {
|
|
37
|
+
this.dbMetrics = [];
|
|
38
|
+
this.cacheStats = { hits: 0, misses: 0 };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.telemetry = new TelemetrySystem();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IDatabase } from './IDatabase';
|
|
2
|
+
import { ToonConfig } from './types';
|
|
3
|
+
export declare class ToonDatabase extends IDatabase {
|
|
4
|
+
private filePath;
|
|
5
|
+
private db;
|
|
6
|
+
private isDirty;
|
|
7
|
+
private isWriting;
|
|
8
|
+
private writeQueue;
|
|
9
|
+
private saveDebounceTimeout;
|
|
10
|
+
private saveInterval;
|
|
11
|
+
private initPromise;
|
|
12
|
+
constructor(config: ToonConfig);
|
|
13
|
+
private _execute;
|
|
14
|
+
private _load;
|
|
15
|
+
private _queueRequest;
|
|
16
|
+
private _processQueue;
|
|
17
|
+
private _scheduleSave;
|
|
18
|
+
private _saveNow;
|
|
19
|
+
private flushSync;
|
|
20
|
+
ensureTable(table: string): Promise<void>;
|
|
21
|
+
insert(table: string, data: Record<string, any>): Promise<number>;
|
|
22
|
+
update(table: string, data: Record<string, any>, where: Record<string, any>): Promise<number>;
|
|
23
|
+
delete(table: string, where: Record<string, any>): Promise<number>;
|
|
24
|
+
select<T = any>(table: string, where?: Record<string, any> | null): Promise<T[]>;
|
|
25
|
+
selectOne<T = any>(table: string, where?: Record<string, any> | null): Promise<T | null>;
|
|
26
|
+
set(table: string, data: Record<string, any>, where: Record<string, any>): Promise<any>;
|
|
27
|
+
bulkInsert(table: string, dataArray: Record<string, any>[]): Promise<number>;
|
|
28
|
+
increment(table: string, incs: Record<string, number>, where?: Record<string, any>): Promise<number>;
|
|
29
|
+
decrement(table: string, decs: Record<string, number>, where?: Record<string, any>): Promise<number>;
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export default ToonDatabase;
|