@rws-framework/db 2.1.9 → 2.1.10

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.
@@ -51,9 +51,10 @@ class DbHelper {
51
51
  fs_1.default.writeFileSync(schemaPath, template);
52
52
  process.env.DB_URL = dbUrl;
53
53
  const endPrisma = 'npx prisma';
54
- const clientPath = path_1.default.join(console_1.rwsPath.findRootWorkspacePath(), 'node_modules', '.prisma', 'client');
54
+ // console.log({cwd: process.cwd()})
55
+ // const clientPath = path.join(rwsPath.findRootWorkspacePath(), 'node_modules', '.prisma', 'client');
55
56
  await console_1.rwsShell.runCommand(`${endPrisma} generate --schema=${schemaPath}`, process.cwd());
56
- leaveFile = true;
57
+ leaveFile = false;
57
58
  log(chalk_1.default.green('[RWS Init]') + ' prisma schema generated from ', schemaPath);
58
59
  if (!leaveFile) {
59
60
  fs_1.default.unlinkSync(schemaPath);
@@ -13,6 +13,7 @@ declare class DBService {
13
13
  private connected;
14
14
  constructor(configService: IDbConfigHandler);
15
15
  private connectToDB;
16
+ reconnect(opts?: IDBClientCreate): void;
16
17
  private createBaseMongoClient;
17
18
  private createBaseMongoClientDB;
18
19
  cloneDatabase(source: string, target: string): Promise<void>;
@@ -42,6 +42,9 @@ class DBService {
42
42
  throw new Error('PRISMA CONNECTION ERROR');
43
43
  }
44
44
  }
45
+ reconnect(opts = null) {
46
+ this.connectToDB(opts);
47
+ }
45
48
  async createBaseMongoClient() {
46
49
  var _a;
47
50
  const dbUrl = ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.dbUrl) || this.configService.get('mongo_url');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/db",
3
3
  "private": false,
4
- "version": "2.1.9",
4
+ "version": "2.1.10",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -68,10 +68,11 @@ export class DbHelper {
68
68
  process.env.DB_URL = dbUrl;
69
69
  const endPrisma = 'npx prisma';
70
70
 
71
- const clientPath = path.join(rwsPath.findRootWorkspacePath(), 'node_modules', '.prisma', 'client');
71
+ // console.log({cwd: process.cwd()})
72
+ // const clientPath = path.join(rwsPath.findRootWorkspacePath(), 'node_modules', '.prisma', 'client');
72
73
  await rwsShell.runCommand(`${endPrisma} generate --schema=${schemaPath}`, process.cwd());
73
74
 
74
- leaveFile = true;
75
+ leaveFile = false;
75
76
  log(chalk.green('[RWS Init]') + ' prisma schema generated from ', schemaPath);
76
77
 
77
78
  if(!leaveFile){
@@ -1,4 +1,4 @@
1
- import {DBService} from '../services/DBService';
1
+ import {DBService, IDBClientCreate} from '../services/DBService';
2
2
  import { IRWSModel } from '../types/IRWSModel';
3
3
  import { IDbConfigHandler } from '../types/DbConfigHandler';
4
4
 
@@ -50,6 +50,11 @@ class DBService {
50
50
  }
51
51
  }
52
52
 
53
+ reconnect(opts: IDBClientCreate = null)
54
+ {
55
+ this.connectToDB(opts);
56
+ }
57
+
53
58
  private async createBaseMongoClient(): Promise<MongoClient>
54
59
  {
55
60
  const dbUrl = this.opts?.dbUrl || this.configService.get('mongo_url');