@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.
Files changed (45) hide show
  1. package/README.md +152 -254
  2. package/dist/bin/zero.d.ts +2 -0
  3. package/dist/bin/zero.js +141 -0
  4. package/dist/database/IDatabase.d.ts +25 -31
  5. package/dist/database/IDatabase.js +38 -0
  6. package/dist/database/cacheWrapper.d.ts +5 -2
  7. package/dist/database/cacheWrapper.js +36 -50
  8. package/dist/database/index.d.ts +3 -2
  9. package/dist/database/index.js +13 -9
  10. package/dist/database/json.d.ts +4 -4
  11. package/dist/database/json.js +85 -87
  12. package/dist/database/mongodb.d.ts +12 -12
  13. package/dist/database/mongodb.js +49 -82
  14. package/dist/database/mysql.d.ts +7 -9
  15. package/dist/database/mysql.js +149 -270
  16. package/dist/database/pg.d.ts +12 -14
  17. package/dist/database/pg.js +113 -222
  18. package/dist/database/redis.d.ts +5 -3
  19. package/dist/database/redis.js +81 -107
  20. package/dist/database/seeder.d.ts +20 -0
  21. package/dist/database/seeder.js +37 -0
  22. package/dist/database/sqlite.d.ts +12 -15
  23. package/dist/database/sqlite.js +108 -223
  24. package/dist/database/telemetry.d.ts +35 -0
  25. package/dist/database/telemetry.js +41 -0
  26. package/dist/database/toon.d.ts +32 -0
  27. package/dist/database/toon.js +209 -0
  28. package/dist/database/types.d.ts +28 -34
  29. package/dist/database/zpack.d.ts +10 -4
  30. package/dist/database/zpack.js +151 -71
  31. package/dist/functions/index.d.ts +16 -0
  32. package/dist/functions/index.js +49 -3
  33. package/dist/functions/security.d.ts +15 -0
  34. package/dist/functions/security.js +46 -0
  35. package/dist/functions/toon.d.ts +7 -0
  36. package/dist/functions/toon.js +118 -0
  37. package/dist/functions/worker.d.ts +5 -0
  38. package/dist/functions/worker.js +35 -0
  39. package/dist/test_v91_advanced.d.ts +1 -0
  40. package/dist/test_v91_advanced.js +48 -0
  41. package/dist/test_v91_basics.d.ts +1 -0
  42. package/dist/test_v91_basics.js +54 -0
  43. package/dist/test_v91_performance.d.ts +1 -0
  44. package/dist/test_v91_performance.js +54 -0
  45. package/package.json +16 -3
@@ -16,124 +16,44 @@ class MySQLDatabase extends IDatabase_1.IDatabase {
16
16
  this._connectionPromise = new Promise(async (resolve, reject) => {
17
17
  try {
18
18
  const connection = await promise_1.default.createConnection({
19
- host: config.host,
19
+ host: config.host || 'localhost',
20
20
  port: config.port || 3306,
21
- user: config.user,
21
+ user: config.username,
22
22
  password: config.password,
23
- typeCast: (field, next) => {
24
- if (field.type === 'TINY' && field.length === 1) {
25
- return (field.string() === '1');
26
- }
27
- if (['INT', 'DECIMAL', 'NEWDECIMAL', 'FLOAT', 'DOUBLE'].includes(field.type)) {
28
- return Number(field.string());
29
- }
30
- return next();
31
- }
32
23
  });
33
- await connection.query(`CREATE DATABASE IF NOT EXISTS
24
+ await connection.query(`CREATE DATABASE IF NOT EXISTS
34
25
  ${config.database}
35
26
  `);
36
27
  await connection.end();
37
28
  this.pool = promise_1.default.createPool({
38
- host: config.host,
29
+ host: config.host || 'localhost',
39
30
  port: config.port || 3306,
40
- user: config.user,
31
+ user: config.username,
41
32
  password: config.password,
42
33
  database: config.database,
43
34
  waitForConnections: true,
44
- connectionLimit: config.connectionLimit || 10,
35
+ connectionLimit: config.poolSize || 10,
45
36
  queueLimit: 0,
46
- typeCast: (field, next) => {
47
- if (field.type === 'TINY' && field.length === 1) {
48
- return (field.string() === '1');
49
- }
50
- if (['INT', 'DECIMAL', 'NEWDECIMAL', 'FLOAT', 'DOUBLE'].includes(field.type)) {
51
- return Number(field.string());
52
- }
53
- return next();
54
- }
55
37
  });
56
38
  this._connected = true;
57
39
  resolve(this.pool);
58
40
  this._processQueue();
59
41
  }
60
42
  catch (error) {
61
- console.error("MySQL connection error:", error);
62
43
  reject(error);
63
44
  }
64
45
  });
65
46
  }
66
- _getColumnType(value) {
67
- if (value === null || value === undefined)
68
- return 'TEXT';
69
- if (typeof value === 'boolean')
70
- return 'BOOLEAN';
71
- if (typeof value === 'number') {
72
- if (Number.isInteger(value)) {
73
- if (value >= -128 && value <= 127)
74
- return 'TINYINT';
75
- if (value >= -32768 && value <= 32767)
76
- return 'SMALLINT';
77
- if (value >= -2147483648 && value <= 2147483647)
78
- return 'INT';
79
- return 'BIGINT';
80
- }
81
- return 'DOUBLE';
82
- }
83
- if (typeof value === 'string') {
84
- const length = value.length;
85
- if (length <= 255)
86
- return 'VARCHAR(255)';
87
- if (length <= 65535)
88
- return 'TEXT';
89
- if (length <= 16777215)
90
- return 'MEDIUMTEXT';
91
- return 'LONGTEXT';
92
- }
93
- if (typeof value === 'object') {
94
- const jsonString = JSON.stringify(value);
95
- return jsonString.length <= 65535 ? 'JSON' : 'LONGTEXT';
96
- }
97
- if (value instanceof Date)
98
- return 'DATETIME';
99
- return 'TEXT';
100
- }
101
- _getBestColumnType(values) {
102
- const types = values.map(val => this._getColumnType(val));
103
- const uniqueTypes = [...new Set(types)];
104
- if (uniqueTypes.length === 1)
105
- return uniqueTypes[0];
106
- const typePriority = {
107
- 'LONGTEXT': 10, 'MEDIUMTEXT': 9, 'TEXT': 8, 'JSON': 7, 'VARCHAR(255)': 6,
108
- 'DATETIME': 5, 'DOUBLE': 4, 'BIGINT': 3, 'INT': 2, 'SMALLINT': 1, 'TINYINT': 0, 'BOOLEAN': -1
47
+ async _execute(op, table, fn) {
48
+ const start = Date.now();
49
+ const execute = async () => {
50
+ const res = await fn();
51
+ this.recordMetric(op, table, Date.now() - start);
52
+ return res;
109
53
  };
110
- return uniqueTypes.sort((a, b) => (typePriority[b] || 0) - (typePriority[a] || 0))[0];
111
- }
112
- async _ensureMissingColumns(table, data) {
113
- const existingColumns = await this.query(`DESCRIBE
114
- ${table}
115
- `).catch(() => []);
116
- const existingColumnNames = existingColumns.map((col) => col.Field);
117
- for (const key of Object.keys(data)) {
118
- if (!existingColumnNames.includes(key)) {
119
- const columnType = this._getColumnType(data[key]);
120
- await this.query(`ALTER TABLE
121
- ${table}
122
- ADD COLUMN
123
- ${key}
124
- ${columnType}`);
125
- }
126
- }
127
- }
128
- async _queueRequest(operation) {
129
- if (this._connected) {
130
- return operation();
131
- }
132
- else {
133
- return new Promise((resolve, reject) => {
134
- this._queue.push({ operation, resolve, reject });
135
- });
136
- }
54
+ if (this._connected)
55
+ return execute();
56
+ return new Promise((resolve, reject) => this._queue.push({ operation: execute, resolve, reject }));
137
57
  }
138
58
  async _processQueue() {
139
59
  if (!this._connected)
@@ -142,8 +62,7 @@ ${key}
142
62
  const item = this._queue.shift();
143
63
  if (item) {
144
64
  try {
145
- const result = await item.operation();
146
- item.resolve(result);
65
+ item.resolve(await item.operation());
147
66
  }
148
67
  catch (error) {
149
68
  item.reject(error);
@@ -152,162 +71,129 @@ ${key}
152
71
  }
153
72
  }
154
73
  async query(sql, params = []) {
155
- return this._queueRequest(async () => {
156
- const pool = await this._connectionPromise;
157
- const [rows] = await pool.execute(sql, params);
158
- return rows;
159
- });
74
+ const pool = await this._connectionPromise;
75
+ const [rows] = await pool.execute(sql, params);
76
+ return rows;
160
77
  }
161
- async ensureTable(table, data = {}) {
162
- return this._queueRequest(async () => {
163
- const escapedTable = promise_1.default.escape(table);
164
- const tables = await this.query(`SHOW TABLES LIKE ${escapedTable}`);
165
- if (tables.length === 0) {
166
- const columnDefinitions = Object.keys(data).map(col => {
167
- const columnType = this._getColumnType(data[col]);
168
- return `
169
- ${col}
170
- ${columnType}`;
171
- });
172
- const columnsPart = columnDefinitions.length > 0 ? ', ' + columnDefinitions.join(", ") : '';
173
- const createTableSQL = `
174
- CREATE TABLE
78
+ async _ensureMissingColumns(table, data) {
79
+ const existingColumns = await this.query(`DESCRIBE
175
80
  ${table}
176
- (
177
- _id INT PRIMARY KEY AUTO_INCREMENT
178
- ${columnsPart}
179
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
180
- `;
181
- await this.query(createTableSQL);
81
+ `).catch(() => []);
82
+ const columnNames = existingColumns.map(col => col.Field);
83
+ for (const key of Object.keys(data)) {
84
+ if (key !== '_id' && !columnNames.includes(key)) {
85
+ await this.query(`ALTER TABLE
86
+ ${table}
87
+ ADD COLUMN
88
+ ${key}
89
+ TEXT`);
182
90
  }
183
- });
91
+ }
184
92
  }
185
- async insert(table, data) {
186
- return this._queueRequest(async () => {
187
- const copy = { ...data };
188
- await this.ensureTable(table, copy);
189
- await this._ensureMissingColumns(table, copy);
190
- const existingColumns = await this.query(`DESCRIBE
93
+ async ensureTable(table, data = {}) {
94
+ const escapedTable = promise_1.default.escape(table);
95
+ const tables = await this.query(`SHOW TABLES LIKE ${escapedTable}`);
96
+ if (tables.length === 0) {
97
+ const defs = Object.keys(data).map(k => `
98
+ ${k}
99
+ TEXT`);
100
+ const columnsPart = defs.length > 0 ? ', ' + defs.join(", ") : '';
101
+ await this.query(`CREATE TABLE
191
102
  ${table}
192
- `);
193
- const primaryKeyColumn = existingColumns.find(col => col.Key === 'PRI' && col.Extra.includes('auto_increment'));
194
- if (primaryKeyColumn && copy[primaryKeyColumn.Field] !== undefined) {
195
- delete copy[primaryKeyColumn.Field];
196
- }
197
- const keys = Object.keys(copy);
198
- const placeholders = keys.map(() => "?").join(",");
199
- const values = Object.values(copy).map(value => this._serializeValue(value));
200
- const sql = `INSERT INTO
103
+ (_id INT PRIMARY KEY AUTO_INCREMENT ${columnsPart}) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
104
+ }
105
+ else {
106
+ await this._ensureMissingColumns(table, data);
107
+ }
108
+ }
109
+ async insert(table, data) {
110
+ await this.runHooks('beforeInsert', table, data);
111
+ return this._execute('insert', table, async () => {
112
+ await this.ensureTable(table, data);
113
+ const keys = Object.keys(data);
114
+ const sql = `INSERT INTO
201
115
  ${table}
202
116
  (${keys.map(k => `
203
117
  ${k}
204
- `).join(",")}) VALUES (${placeholders})`;
205
- const result = await this.query(sql, values);
118
+ `).join(",")}) VALUES (${keys.map(() => '?').join(",")})`;
119
+ const result = await this.query(sql, Object.values(data).map(v => typeof v === 'object' ? JSON.stringify(v) : v));
120
+ const finalData = { _id: result.insertId, ...data };
121
+ await this.runHooks('afterInsert', table, finalData);
206
122
  return result.insertId;
207
123
  });
208
124
  }
209
125
  async update(table, data, where) {
210
- return this._queueRequest(async () => {
126
+ await this.runHooks('beforeUpdate', table, { data, where });
127
+ return this._execute('update', table, async () => {
211
128
  await this.ensureTable(table, { ...data, ...where });
212
- await this._ensureMissingColumns(table, { ...data, ...where });
213
- const setString = Object.keys(data).map(k => `
129
+ const set = Object.keys(data).map(k => `
214
130
  ${k}
215
131
  = ?`).join(", ");
216
- const whereString = Object.keys(where).map(k => `
217
- ${k}
218
- = ?`).join(" AND ");
219
- const sql = `UPDATE
132
+ const wKeys = Object.keys(where);
133
+ const sql = `UPDATE
220
134
  ${table}
221
- SET ${setString} WHERE ${whereString}`;
222
- const values = [...Object.values(data).map(v => this._serializeValue(v)), ...Object.values(where).map(v => this._serializeValue(v))];
223
- const result = await this.query(sql, values);
135
+ SET ${set} WHERE ${wKeys.map(k => `
136
+ ${k}
137
+ = ?`).join(" AND ")}`;
138
+ const result = await this.query(sql, [...Object.values(data).map(v => typeof v === 'object' ? JSON.stringify(v) : v), ...Object.values(where).map(v => typeof v === 'object' ? JSON.stringify(v) : v)]);
224
139
  return result.affectedRows;
225
140
  });
226
141
  }
227
142
  async delete(table, where) {
228
- return this._queueRequest(async () => {
229
- if (!where || Object.keys(where).length === 0)
230
- return 0;
231
- await this.ensureTable(table, { ...where });
232
- await this._ensureMissingColumns(table, where);
233
- const whereString = Object.keys(where).map(k => `
234
- ${k}
235
- = ?`).join(" AND ");
236
- const sql = `DELETE FROM
143
+ await this.runHooks('beforeDelete', table, where);
144
+ return this._execute('delete', table, async () => {
145
+ await this.ensureTable(table, where);
146
+ const keys = Object.keys(where);
147
+ const sql = `DELETE FROM
237
148
  ${table}
238
- WHERE ${whereString}`;
239
- const result = await this.query(sql, Object.values(where).map(v => this._serializeValue(v)));
149
+ WHERE ${keys.map(k => `
150
+ ${k}
151
+ = ?`).join(" AND ")}`;
152
+ const result = await this.query(sql, Object.values(where).map(v => typeof v === 'object' ? JSON.stringify(v) : v));
240
153
  return result.affectedRows;
241
154
  });
242
155
  }
243
156
  async select(table, where = null) {
244
- return this._queueRequest(async () => {
157
+ return this._execute('select', table, async () => {
245
158
  await this.ensureTable(table, where || {});
246
- if (where && Object.keys(where).length > 0) {
247
- await this._ensureMissingColumns(table, where);
248
- }
249
- let sql = `SELECT * FROM
159
+ const keys = where ? Object.keys(where) : [];
160
+ const sql = `SELECT * FROM
250
161
  ${table}
251
- `;
252
- let params = [];
253
- if (where && Object.keys(where).length > 0) {
254
- const whereString = Object.keys(where).map(k => `
162
+ ` + (keys.length ? ' WHERE ' + keys.map(k => `
255
163
  ${k}
256
- = ?`).join(" AND ");
257
- sql += ` WHERE ${whereString}`;
258
- params = Object.values(where).map(v => this._serializeValue(v));
259
- }
260
- const rows = await this.query(sql, params);
164
+ = ?`).join(" AND ") : '');
165
+ const rows = await this.query(sql, keys.map(k => typeof where[k] === 'object' ? JSON.stringify(where[k]) : where[k]));
261
166
  return rows.map((row) => {
262
- const newRow = {};
263
- for (const key in row) {
264
- newRow[key] = this._deserializeValue(row[key]);
167
+ const nr = {};
168
+ for (const k in row) {
169
+ try {
170
+ nr[k] = JSON.parse(row[k]);
171
+ }
172
+ catch {
173
+ nr[k] = row[k];
174
+ }
265
175
  }
266
- return newRow;
176
+ return nr;
267
177
  });
268
178
  });
269
179
  }
270
- async set(table, data, where) {
271
- return this._queueRequest(async () => {
272
- const existing = await this.select(table, where);
273
- if (existing.length === 0) {
274
- return await this.insert(table, { ...where, ...data });
275
- }
276
- else {
277
- return await this.update(table, data, where);
278
- }
279
- });
280
- }
281
180
  async selectOne(table, where = null) {
282
- const results = await this.select(table, where);
283
- return results[0] || null;
181
+ const res = await this.select(table, where);
182
+ return res[0] || null;
183
+ }
184
+ async set(table, data, where) {
185
+ const existing = await this.selectOne(table, where);
186
+ return existing ? this.update(table, data, where) : this.insert(table, { ...where, ...data });
284
187
  }
285
188
  async bulkInsert(table, dataArray) {
286
- return this._queueRequest(async () => {
287
- if (!Array.isArray(dataArray) || dataArray.length === 0)
288
- return 0;
189
+ if (!dataArray.length)
190
+ return 0;
191
+ return this._execute('bulkInsert', table, async () => {
289
192
  await this.ensureTable(table, dataArray[0]);
290
- const existingColumns = await this.query(`DESCRIBE
291
- ${table}
292
- `);
293
- const existingColumnNames = existingColumns.map((col) => col.Field);
294
- const allKeys = new Set();
295
- dataArray.forEach(obj => Object.keys(obj).forEach(key => allKeys.add(key)));
296
- for (const key of allKeys) {
297
- if (!existingColumnNames.includes(key)) {
298
- const columnValues = dataArray.map(obj => obj[key]).filter(val => val !== undefined && val !== null);
299
- const columnType = columnValues.length > 0 ? this._getBestColumnType(columnValues) : 'TEXT';
300
- await this.query(`ALTER TABLE
301
- ${table}
302
- ADD COLUMN
303
- ${key}
304
- ${columnType}`);
305
- }
306
- }
307
- const keys = Array.from(allKeys);
193
+ const keys = Object.keys(dataArray[0]);
308
194
  const placeholders = dataArray.map(() => `(${keys.map(() => '?').join(',')})`).join(',');
309
195
  const values = dataArray.flatMap(obj => keys.map(k => this._serializeValue(obj[k])));
310
- const sql = `INSERT INTO
196
+ const sql = `INSERT INTO
311
197
  ${table}
312
198
  (${keys.map(k => `
313
199
  ${k}
@@ -316,69 +202,62 @@ ${k}
316
202
  return result.affectedRows;
317
203
  });
318
204
  }
319
- async close() {
320
- if (this.pool)
321
- await this.pool.end();
322
- }
323
- _serializeValue(value) {
324
- if (value instanceof Date)
325
- return value.toISOString().slice(0, 19).replace('T', ' ');
326
- if (Array.isArray(value) || (typeof value === 'object' && value !== null))
327
- return JSON.stringify(value);
328
- return value;
329
- }
330
- _deserializeValue(value) {
331
- try {
332
- if (typeof value === 'string' && (value.startsWith('[') || value.startsWith('{'))) {
333
- const parsed = JSON.parse(value);
334
- if (typeof parsed === 'object' && parsed !== null)
335
- return parsed;
336
- }
337
- }
338
- catch (e) { }
339
- return value;
340
- }
341
- async increment(table, increments, where = {}) {
342
- return this._queueRequest(async () => {
343
- const incrementClauses = Object.keys(increments).map(field => `
344
- ${field}
345
- =
346
- ${field}
205
+ async increment(table, incs, where) {
206
+ return this._execute('increment', table, async () => {
207
+ await this.ensureTable(table, where);
208
+ const set = Object.keys(incs).map(f => `
209
+ ${f}
210
+ =
211
+ ${f}
347
212
  + ?`).join(', ');
348
- const incrementValues = Object.values(increments);
349
- const { whereClause, values: whereValues } = this._buildWhereClause(where);
350
- const sql = `UPDATE
213
+ const wKeys = Object.keys(where);
214
+ const sql = `UPDATE
351
215
  ${table}
352
- SET ${incrementClauses}${whereClause}`;
353
- const result = await this.query(sql, [...incrementValues, ...whereValues]);
216
+ SET ${set} WHERE ${wKeys.map(k => `
217
+ ${k}
218
+ = ?`).join(" AND ")}`;
219
+ const result = await this.query(sql, [...Object.values(incs), ...Object.values(where).map(v => typeof v === 'object' ? JSON.stringify(v) : v)]);
354
220
  return result.affectedRows;
355
221
  });
356
222
  }
357
- async decrement(table, decrements, where = {}) {
358
- return this._queueRequest(async () => {
359
- const decrementClauses = Object.keys(decrements).map(field => `
360
- ${field}
361
- =
362
- ${field}
363
- + ?`).join(', ');
364
- const decrementValues = Object.values(decrements);
365
- const { whereClause, values: whereValues } = this._buildWhereClause(where);
366
- const sql = `UPDATE
367
- ${table}
368
- SET ${decrementClauses}${whereClause}`;
369
- const result = await this.query(sql, [...decrementValues, ...whereValues]);
370
- return result.affectedRows;
371
- });
223
+ async decrement(table, decs, where) {
224
+ const incs = {};
225
+ for (const k in decs)
226
+ incs[k] = -decs[k];
227
+ return this.increment(table, incs, where);
228
+ }
229
+ async close() { if (this.pool)
230
+ await this.pool.end(); }
231
+ _getColumnType(v) {
232
+ if (v === null || v === undefined)
233
+ return 'TEXT';
234
+ if (typeof v === 'boolean')
235
+ return 'BOOLEAN';
236
+ if (typeof v === 'number')
237
+ return Number.isInteger(v) ? 'INT' : 'DOUBLE';
238
+ if (v instanceof Date)
239
+ return 'DATETIME';
240
+ if (typeof v === 'object')
241
+ return 'JSON';
242
+ return 'TEXT';
372
243
  }
373
- _buildWhereClause(where = {}) {
374
- const conditions = Object.keys(where);
375
- if (conditions.length === 0)
244
+ _serializeValue(v) {
245
+ if (v instanceof Date)
246
+ return v.toISOString().slice(0, 19).replace('T', ' ');
247
+ return (typeof v === 'object' && v !== null) ? JSON.stringify(v) : v;
248
+ }
249
+ _buildWhereClause(where) {
250
+ if (!where)
376
251
  return { whereClause: '', values: [] };
377
- const whereClause = ' WHERE ' + conditions.map(key => `
378
- ${key}
379
- = ?`).join(' AND ');
380
- const values = Object.values(where).map(v => this._serializeValue(v));
381
- return { whereClause, values };
252
+ const keys = Object.keys(where);
253
+ if (!keys.length)
254
+ return { whereClause: '', values: [] };
255
+ return {
256
+ whereClause: 'WHERE ' + keys.map(k => `
257
+ ${k}
258
+ = ?`).join(' AND '),
259
+ values: Object.values(where).map(v => this._serializeValue(v))
260
+ };
382
261
  }
383
262
  }
384
263
  exports.MySQLDatabase = MySQLDatabase;
@@ -7,24 +7,22 @@ export declare class PostgreSQLDatabase extends IDatabase {
7
7
  private _connected;
8
8
  private _connectionPromise;
9
9
  constructor(config: PostgreSQLConfig);
10
- private _getColumnType;
11
- private _getBestColumnType;
12
- private _ensureMissingColumns;
13
- private _queueRequest;
10
+ private _execute;
14
11
  private _processQueue;
15
12
  query(sql: string, params?: any[]): Promise<any>;
16
- ensureTable(table: string, data?: Record<string, any>): Promise<void>;
17
- insert(table: string, data: Record<string, any>): Promise<any>;
18
- update(table: string, data: Record<string, any>, where: Record<string, any>): Promise<number>;
19
- delete(table: string, where: Record<string, any>): Promise<number>;
20
- select<T = any>(table: string, where?: Record<string, any> | null): Promise<T[]>;
21
- set(table: string, data: Record<string, any>, where: Record<string, any>): Promise<any>;
22
- selectOne<T = any>(table: string, where?: Record<string, any> | null): Promise<T | null>;
23
- bulkInsert(table: string, dataArray: Record<string, any>[]): Promise<number>;
13
+ ensureTable(table: string, data?: any): Promise<void>;
14
+ insert(table: string, data: any): Promise<any>;
15
+ update(table: string, data: any, where: any): Promise<number>;
16
+ delete(table: string, where: any): Promise<number>;
17
+ select<T = any>(table: string, where?: any): Promise<T[]>;
18
+ selectOne<T = any>(table: string, where?: any): Promise<T | null>;
19
+ set(table: string, data: any, where: any): Promise<any>;
20
+ bulkInsert(table: string, dataArray: any[]): Promise<number>;
21
+ increment(table: string, incs: Record<string, number>, where: any): Promise<number>;
22
+ decrement(table: string, decs: Record<string, number>, where: any): Promise<number>;
24
23
  close(): Promise<void>;
24
+ private _getColumnType;
25
25
  private _serializeValue;
26
- increment(table: string, increments: Record<string, number>, where?: Record<string, any>): Promise<number>;
27
- decrement(table: string, decrements: Record<string, number>, where?: Record<string, any>): Promise<number>;
28
26
  private _buildWhereClause;
29
27
  }
30
28
  export default PostgreSQLDatabase;