ztechno_core 0.0.77 → 0.0.79

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.
@@ -63,5 +63,6 @@ export declare class ZSQLService {
63
63
  ): Promise<T[]>;
64
64
  private formatQueryParams;
65
65
  private isSqlDate;
66
+ changeDatabase(newDatabase: string): Promise<void>;
66
67
  }
67
68
  export {};
@@ -148,5 +148,27 @@ class ZSQLService {
148
148
  }
149
149
  return false;
150
150
  }
151
+ async changeDatabase(newDatabase) {
152
+ return new Promise((resolve, reject) => {
153
+ this.pool.end((err) => {
154
+ if (err) {
155
+ reject(err);
156
+ return;
157
+ }
158
+ this.databaseName = newDatabase;
159
+ const newOptions = { ...this.options, database: newDatabase };
160
+ this.pool = mysql.createPool(Object.assign({}, this.defaultPoolconfig, newOptions));
161
+ this.pool.on('connection', (connection) => {
162
+ connection.on('error', (err) => {
163
+ this.triggerEvent('err', err);
164
+ });
165
+ connection.on('close', (err) => {
166
+ this.triggerEvent('err', err);
167
+ });
168
+ });
169
+ resolve();
170
+ });
171
+ });
172
+ }
151
173
  }
152
174
  exports.ZSQLService = ZSQLService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",