tspace-mysql 1.1.2 → 1.1.3

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.
@@ -1,195 +1,226 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
2
  Object.defineProperty(exports, "__esModule", { value: true });
28
3
  exports.Blueprint = void 0;
29
- var Blueprint = /** @class */ (function () {
30
- function Blueprint() {
31
- this.type = '';
32
- this.attrbuites = [];
33
- }
34
- Blueprint.prototype._addAssignType = function (type) {
35
- if (this.type)
36
- return this;
37
- this.type = type;
38
- return this;
39
- };
40
- Blueprint.prototype._addAssignAttrbuite = function (attrbuite) {
41
- this.attrbuites = __spreadArray(__spreadArray([], __read(this.attrbuites), false), [attrbuite], false);
42
- return this;
43
- };
44
- Blueprint.prototype.int = function () {
4
+ class Blueprint {
5
+ type = '';
6
+ attrbuites = [];
7
+ /**
8
+ * Assign type 'int' in table
9
+ * @return {this} this
10
+ */
11
+ int() {
45
12
  this._addAssignType('INT');
46
13
  return this;
47
- };
14
+ }
48
15
  /**
49
- * Assign type
50
- * @param {number}
16
+ * Assign type 'TINYINT' in table
17
+ * @param {number} number
18
+ * @return {this} this
51
19
  */
52
- Blueprint.prototype.tinyInt = function (n) {
53
- if (n === void 0) { n = 1; }
54
- this._addAssignType("TINYINT(".concat(n, ")"));
20
+ tinyInt(number = 1) {
21
+ this._addAssignType(`TINYINT(${number})`);
55
22
  return this;
56
- };
23
+ }
57
24
  /**
58
- * Assign type
59
- * @param {number}
25
+ * Assign type 'BIGINT' in table
26
+ * @param {number} number [number = 10]
27
+ * @return {this} this
60
28
  */
61
- Blueprint.prototype.bigInt = function (n) {
62
- if (n === void 0) { n = 10; }
63
- this._addAssignType("BIGINT(".concat(n, ")"));
29
+ bigInt(number = 10) {
30
+ this._addAssignType(`BIGINT(${number})`);
64
31
  return this;
65
- };
32
+ }
66
33
  /**
67
- * Assign type
34
+ * Assign type 'DOUBLE' in table
68
35
  * @param {number} length between 1-255
69
36
  * @param {number} decimal 0.000...n
37
+ * @return {this} this
70
38
  */
71
- Blueprint.prototype.double = function (length, decimal) {
72
- if (length === void 0) { length = 0; }
73
- if (decimal === void 0) { decimal = 0; }
39
+ double(length = 0, decimal = 0) {
74
40
  if (!length || !decimal) {
75
- this._addAssignType("DOUBLE");
41
+ this._addAssignType(`DOUBLE`);
76
42
  return this;
77
43
  }
78
- this._addAssignType("DOUBLE(".concat(length, ",").concat(decimal, ")"));
44
+ this._addAssignType(`DOUBLE(${length},${decimal})`);
79
45
  return this;
80
- };
46
+ }
81
47
  /**
82
- * Assign type
48
+ * Assign type 'FLOAT' in table
83
49
  * @param {number} length between 1-255
84
50
  * @param {number} decimal 0.000...n
51
+ * @return {this} this
85
52
  */
86
- Blueprint.prototype.float = function (length, decimal) {
87
- if (length === void 0) { length = 0; }
88
- if (decimal === void 0) { decimal = 0; }
53
+ float(length = 0, decimal = 0) {
89
54
  if (!length || !decimal) {
90
- this._addAssignType("FLOAT");
55
+ this._addAssignType(`FLOAT`);
91
56
  return this;
92
57
  }
93
- this._addAssignType("FLOAT(".concat(length, ",").concat(decimal, ")"));
58
+ this._addAssignType(`FLOAT(${length},${decimal})`);
94
59
  return this;
95
- };
60
+ }
96
61
  /**
97
- * Assign type
98
- * @param {number} length string between 1-255
62
+ * Assign type 'VARCHAR' in table
63
+ * @param {number} length [length = 100] length of string
64
+ * @return {this} this
99
65
  */
100
- Blueprint.prototype.varchar = function (n) {
101
- if (n === void 0) { n = 100; }
102
- if (n > 255)
103
- n = 255;
104
- this._addAssignType("VARCHAR(".concat(n, ")"));
66
+ varchar(length = 100) {
67
+ if (length > 255)
68
+ length = 255;
69
+ this._addAssignType(`VARCHAR(${length})`);
105
70
  return this;
106
- };
71
+ }
107
72
  /**
108
- * Assign type
109
- * @param {number} length string between 1-255
73
+ * Assign type 'CHAR' in table
74
+ * @param {number} length [length = 1] length of string
75
+ * @return {this} this
110
76
  */
111
- Blueprint.prototype.char = function (n) {
112
- if (n === void 0) { n = 1; }
113
- this._addAssignType("CHAR(".concat(n, ")"));
77
+ char(length = 1) {
78
+ this._addAssignType(`CHAR(${length})`);
114
79
  return this;
115
- };
116
- Blueprint.prototype.longText = function () {
117
- this._addAssignType("LONGTEXT");
80
+ }
81
+ /**
82
+ * Assign type 'LONGTEXT' in table
83
+ * @return {this} this
84
+ */
85
+ longText() {
86
+ this._addAssignType(`LONGTEXT`);
118
87
  return this;
119
- };
120
- Blueprint.prototype.mediumText = function () {
121
- this._addAssignType("MEDIUMTEXT");
88
+ }
89
+ /**
90
+ * Assign type 'MEDIUMTEXT' in table
91
+ * @param {number} length [length = 1] length of string
92
+ * @return {this} this
93
+ */
94
+ mediumText() {
95
+ this._addAssignType(`MEDIUMTEXT`);
122
96
  return this;
123
- };
124
- Blueprint.prototype.tinyText = function () {
125
- this._addAssignType("TINYTEXT");
97
+ }
98
+ /**
99
+ * Assign type 'TINYTEXT' in table
100
+ * @param {number} length [length = 1] length of string
101
+ * @return {this} this
102
+ */
103
+ tinyText() {
104
+ this._addAssignType(`TINYTEXT`);
126
105
  return this;
127
- };
128
- Blueprint.prototype.text = function () {
129
- this._addAssignType("TEXT");
106
+ }
107
+ /**
108
+ * Assign type 'TEXT' in table
109
+ * @param {number} length [length = 1] length of string
110
+ * @return {this} this
111
+ */
112
+ text() {
113
+ this._addAssignType(`TEXT`);
130
114
  return this;
131
- };
115
+ }
132
116
  /**
133
- * Assign type
134
- * @param {...string} enum n1, n2, n3, ...n
117
+ * Assign type 'ENUM'
118
+ * @param {...string} enums n1, n2, n3, ...n
119
+ * @return {this} this
135
120
  */
136
- Blueprint.prototype.enum = function () {
137
- var enums = [];
138
- for (var _i = 0; _i < arguments.length; _i++) {
139
- enums[_i] = arguments[_i];
140
- }
141
- this._addAssignType("ENUM('".concat(enums, "')"));
121
+ enum(...enums) {
122
+ this._addAssignType(`ENUM('${enums}')`);
123
+ return this;
124
+ }
125
+ /**
126
+ * Assign type 'DATE' in table
127
+ * @return {this} this
128
+ */
129
+ date() {
130
+ this._addAssignType(`DATE`);
142
131
  return this;
143
- };
144
- Blueprint.prototype.date = function () {
145
- this._addAssignType("DATE");
132
+ }
133
+ /**
134
+ * Assign type 'DATETIME' in table
135
+ * @return {this} this
136
+ */
137
+ dateTime() {
138
+ this._addAssignType(`DATETIME`);
146
139
  return this;
147
- };
148
- Blueprint.prototype.dateTime = function () {
149
- this._addAssignType("DATETIME");
140
+ }
141
+ /**
142
+ * Assign type 'TIMESTAMP' in table
143
+ * @return {this} this
144
+ */
145
+ timestamp() {
146
+ this._addAssignType(`TIMESTAMP`);
150
147
  return this;
151
- };
152
- Blueprint.prototype.timestamp = function () {
153
- this._addAssignType("TIMESTAMP");
148
+ }
149
+ /**
150
+ * Assign type 'UNSIGNED' in table
151
+ * @return {this} this
152
+ */
153
+ unsigned() {
154
+ this._addAssignAttrbuite(`UNSIGNED`);
154
155
  return this;
155
- };
156
- Blueprint.prototype.unsigned = function () {
157
- this._addAssignAttrbuite("UNSIGNED");
156
+ }
157
+ /**
158
+ * Assign type 'UNIQUE' in table
159
+ * @return {this} this
160
+ */
161
+ unique() {
162
+ this._addAssignAttrbuite(`UNIQUE`);
158
163
  return this;
159
- };
160
- Blueprint.prototype.unique = function () {
161
- this._addAssignAttrbuite("UNIQUE");
164
+ }
165
+ /**
166
+ * Assign type 'NULL' in table
167
+ * @return {this} this
168
+ */
169
+ null() {
170
+ this._addAssignAttrbuite(`NULL`);
162
171
  return this;
163
- };
164
- Blueprint.prototype.null = function () {
165
- this._addAssignAttrbuite("NULL");
172
+ }
173
+ /**
174
+ * Assign type 'NOT NULL' in table
175
+ * @return {this} this
176
+ */
177
+ notNull() {
178
+ this._addAssignAttrbuite(`NOT NULL`);
166
179
  return this;
167
- };
168
- Blueprint.prototype.notNull = function () {
169
- this._addAssignAttrbuite("NOT NULL");
180
+ }
181
+ /**
182
+ * Assign type 'PRIMARY KEY' in table
183
+ * @return {this} this
184
+ */
185
+ primary() {
186
+ this._addAssignAttrbuite(`PRIMARY KEY`);
170
187
  return this;
171
- };
172
- Blueprint.prototype.primary = function () {
173
- this._addAssignAttrbuite("PRIMARY KEY");
188
+ }
189
+ /**
190
+ * Assign attrbuites 'default' in table
191
+ * @param {string | number} n default value
192
+ * @return {this} this
193
+ */
194
+ default(n) {
195
+ this._addAssignAttrbuite(`DEFAULT '${n}'`);
174
196
  return this;
175
- };
197
+ }
176
198
  /**
177
- * Assign attrbuites
178
- * @param {string | number} default value
199
+ * Assign attrbuites 'default currentTimestamp' in table
200
+ * @return {this} this
179
201
  */
180
- Blueprint.prototype.default = function (n) {
181
- this._addAssignAttrbuite("DEFAULT '".concat(n, "'"));
202
+ currentTimestamp() {
203
+ this._addAssignAttrbuite(`DEFAULT CURRENT_TIMESTAMP`);
182
204
  return this;
183
- };
184
- Blueprint.prototype.defaultTimestamp = function () {
185
- this._addAssignAttrbuite("DEFAULT CURRENT_TIMESTAMP");
205
+ }
206
+ /**
207
+ * Assign attrbuites 'autoIncrement' in table
208
+ * @return {this} this
209
+ */
210
+ autoIncrement() {
211
+ this._addAssignAttrbuite(`AUTO_INCREMENT`);
212
+ return this;
213
+ }
214
+ _addAssignType(type) {
215
+ if (this.type)
216
+ return this;
217
+ this.type = type;
186
218
  return this;
187
- };
188
- Blueprint.prototype.autoIncrement = function () {
189
- this._addAssignAttrbuite("AUTO_INCREMENT");
219
+ }
220
+ _addAssignAttrbuite(attrbuite) {
221
+ this.attrbuites = [...this.attrbuites, attrbuite];
190
222
  return this;
191
- };
192
- return Blueprint;
193
- }());
223
+ }
224
+ }
194
225
  exports.Blueprint = Blueprint;
195
226
  exports.default = Blueprint;
@@ -1,6 +1,6 @@
1
1
  import { AbstractDB } from './AbstractDB';
2
+ import { ConnectionTransaction } from '../connection';
2
3
  declare class DB extends AbstractDB {
3
- [x: string]: any;
4
4
  constructor(table?: string);
5
5
  /**
6
6
  * Assign table name
@@ -9,10 +9,33 @@ declare class DB extends AbstractDB {
9
9
  */
10
10
  table(table: string): this;
11
11
  /**
12
- * transaction query rollback & commit
13
- * @return {promise<any>}
12
+ * Get a connection
13
+ * @return {ConnectionTransaction}
14
+ * @type {object} connection
15
+ * @property {function} connection.query - execute query sql then release connection to pool
16
+ * @property {function} connection.startTransaction - start transaction of query
17
+ * @property {function} connection.commit - commit transaction of query
18
+ * @property {function} connection.rollback - rollback transaction of query
19
+ */
20
+ beginTransaction(): Promise<ConnectionTransaction>;
21
+ /**
22
+ * Assign table name
23
+ * @static
24
+ * @param {string} table table name
25
+ * @return {DB} DB
26
+ */
27
+ static table(table: string): DB;
28
+ /**
29
+ * Get a connection
30
+ * @static
31
+ * @return {ConnectionTransaction}
32
+ * @type {object} connection
33
+ * @property {function} connection.query - execute query sql then release connection to pool
34
+ * @property {function} connection.startTransaction - start transaction of query
35
+ * @property {function} connection.commit - commit transaction of query
36
+ * @property {function} connection.rollback - rollback transaction of query
14
37
  */
15
- beginTransaction(): Promise<any>;
38
+ static beginTransaction(): Promise<ConnectionTransaction>;
16
39
  private _initialDB;
17
40
  private _setupDB;
18
41
  }
@@ -1,186 +1,94 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
- return new (P || (P = Promise))(function (resolve, reject) {
31
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
- step((generator = generator.apply(thisArg, _arguments || [])).next());
35
- });
36
- };
37
- var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
- function verb(n) { return function (v) { return step([n, v]); }; }
41
- function step(op) {
42
- if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
44
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
- if (y = 0, t) op = [op[0] & 2, t.value];
46
- switch (op[0]) {
47
- case 0: case 1: t = op; break;
48
- case 4: _.label++; return { value: op[1], done: false };
49
- case 5: _.label++; y = op[1]; op = [0]; continue;
50
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
- default:
52
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
- if (t[2]) _.ops.pop();
57
- _.trys.pop(); continue;
58
- }
59
- op = body.call(thisArg, _);
60
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
- }
63
- };
64
- var __values = (this && this.__values) || function(o) {
65
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
66
- if (m) return m.call(o);
67
- if (o && typeof o.length === "number") return {
68
- next: function () {
69
- if (o && i >= o.length) o = void 0;
70
- return { value: o && o[i++], done: !o };
71
- }
72
- };
73
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
74
- };
75
2
  Object.defineProperty(exports, "__esModule", { value: true });
76
3
  exports.DB = void 0;
77
- var AbstractDB_1 = require("./AbstractDB");
78
- var ProxyHandler_1 = require("./ProxyHandler");
79
- var DB = /** @class */ (function (_super) {
80
- __extends(DB, _super);
81
- function DB(table) {
82
- var _this = _super.call(this) || this;
83
- _this._initialDB();
4
+ const AbstractDB_1 = require("./AbstractDB");
5
+ const ProxyHandler_1 = require("./ProxyHandler");
6
+ class DB extends AbstractDB_1.AbstractDB {
7
+ constructor(table) {
8
+ super();
9
+ this._initialDB();
84
10
  if (table)
85
- _this.table(table);
86
- return new Proxy(_this, ProxyHandler_1.proxyHandler);
11
+ this.table(table);
12
+ return new Proxy(this, ProxyHandler_1.proxyHandler);
87
13
  }
88
14
  /**
89
15
  * Assign table name
90
16
  * @param {string} table table name
91
17
  * @return {this} this
92
18
  */
93
- DB.prototype.table = function (table) {
94
- this.$db.set('SELECT', "".concat(this.$constants('SELECT'), " *"));
95
- this.$db.set('TABLE_NAME', "`".concat(table, "`"));
96
- this.$db.set('FROM', "".concat(this.$constants('FROM')));
19
+ table(table) {
20
+ this.$db.set('SELECT', `${this.$constants('SELECT')} *`);
21
+ this.$db.set('TABLE_NAME', `\`${table}\``);
22
+ this.$db.set('FROM', `${this.$constants('FROM')}`);
97
23
  return this;
98
- };
24
+ }
25
+ /**
26
+ * Get a connection
27
+ * @return {ConnectionTransaction}
28
+ * @type {object} connection
29
+ * @property {function} connection.query - execute query sql then release connection to pool
30
+ * @property {function} connection.startTransaction - start transaction of query
31
+ * @property {function} connection.commit - commit transaction of query
32
+ * @property {function} connection.rollback - rollback transaction of query
33
+ */
34
+ async beginTransaction() {
35
+ const pool = await this.$pool.load();
36
+ return await pool.connection();
37
+ }
99
38
  /**
100
- * transaction query rollback & commit
101
- * @return {promise<any>}
39
+ * Assign table name
40
+ * @static
41
+ * @param {string} table table name
42
+ * @return {DB} DB
102
43
  */
103
- DB.prototype.beginTransaction = function () {
104
- return __awaiter(this, void 0, void 0, function () {
105
- var transaction;
106
- var _this = this;
107
- return __generator(this, function (_a) {
108
- transaction = {
109
- rollback: function () { return __awaiter(_this, void 0, void 0, function () {
110
- var transaction, _a, _b, query, e_1_1;
111
- var e_1, _c;
112
- return __generator(this, function (_d) {
113
- switch (_d.label) {
114
- case 0:
115
- transaction = this.$db.get('TRANSACTION');
116
- if (!(transaction === null || transaction === void 0 ? void 0 : transaction.query.length))
117
- return [2 /*return*/, false];
118
- _d.label = 1;
119
- case 1:
120
- _d.trys.push([1, 6, 7, 8]);
121
- _a = __values(transaction.query), _b = _a.next();
122
- _d.label = 2;
123
- case 2:
124
- if (!!_b.done) return [3 /*break*/, 5];
125
- query = _b.value;
126
- if (query.id === '' || query.table === '' || query.id == null || query.table == null) {
127
- return [2 /*return*/, false];
128
- }
129
- return [4 /*yield*/, new DB()
130
- .table(query.table)
131
- .where('id', query.id)
132
- .delete()];
133
- case 3:
134
- _d.sent();
135
- _d.label = 4;
136
- case 4:
137
- _b = _a.next();
138
- return [3 /*break*/, 2];
139
- case 5: return [3 /*break*/, 8];
140
- case 6:
141
- e_1_1 = _d.sent();
142
- e_1 = { error: e_1_1 };
143
- return [3 /*break*/, 8];
144
- case 7:
145
- try {
146
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
147
- }
148
- finally { if (e_1) throw e_1.error; }
149
- return [7 /*endfinally*/];
150
- case 8: return [2 /*return*/, true];
151
- }
152
- });
153
- }); },
154
- query: []
155
- };
156
- this.$db.set('TRANSACTION', transaction);
157
- return [2 /*return*/, transaction];
158
- });
159
- });
160
- };
161
- DB.prototype._initialDB = function () {
44
+ static table(table) {
45
+ const self = new this();
46
+ self.$db.set('SELECT', `${self.$constants('SELECT')} *`);
47
+ self.$db.set('TABLE_NAME', `\`${table}\``);
48
+ self.$db.set('FROM', `${self.$constants('FROM')}`);
49
+ return self;
50
+ }
51
+ /**
52
+ * Get a connection
53
+ * @static
54
+ * @return {ConnectionTransaction}
55
+ * @type {object} connection
56
+ * @property {function} connection.query - execute query sql then release connection to pool
57
+ * @property {function} connection.startTransaction - start transaction of query
58
+ * @property {function} connection.commit - commit transaction of query
59
+ * @property {function} connection.rollback - rollback transaction of query
60
+ */
61
+ static async beginTransaction() {
62
+ const self = new this();
63
+ const pool = await self.$pool.load();
64
+ return await pool.connection();
65
+ }
66
+ _initialDB() {
162
67
  this.$db = this._setupDB();
163
68
  return this;
164
- };
165
- DB.prototype._setupDB = function () {
166
- var db = new Map(Object.entries(__assign({}, this.$constants('DB'))));
69
+ }
70
+ _setupDB() {
71
+ let db = new Map(Object.entries({ ...this.$constants('DB') }));
167
72
  return {
168
- get: function (key) {
73
+ get: (key) => {
169
74
  if (key == null)
170
75
  return db;
171
76
  if (!db.has(key))
172
- throw new Error("can't get this [".concat(key, "]"));
77
+ throw new Error(`can't get this [${key}]`);
173
78
  return db.get(key);
174
79
  },
175
- set: function (key, value) {
80
+ set: (key, value) => {
176
81
  if (!db.has(key))
177
- throw new Error("can't set this [".concat(key, "]"));
82
+ throw new Error(`can't set this [${key}]`);
178
83
  db.set(key, value);
179
84
  return;
85
+ },
86
+ clone: (data) => {
87
+ db = new Map(Object.entries({ ...data }));
88
+ return;
180
89
  }
181
90
  };
182
- };
183
- return DB;
184
- }(AbstractDB_1.AbstractDB));
91
+ }
92
+ }
185
93
  exports.DB = DB;
186
94
  exports.default = DB;