@reldens/storage 0.16.0 → 0.18.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.
@@ -20,6 +20,8 @@ class BaseDataServer
20
20
  this.poolConfig = sc.get(props, 'poolConfig', {});
21
21
  this.connectStringOptions = sc.get(props, 'connectStringOptions', '');
22
22
  this.connectString = sc.get(props, 'connectString', this.createConnectionString());
23
+ this.debug = sc.get(props, 'debug', false);
24
+ this.multipleStatements = sc.get(props, 'multipleStatements', false);
23
25
  this.rawModel = sc.get(props, 'rawModel', false);
24
26
  this.name = sc.get(props, 'name', false);
25
27
  this.initialized = sc.get(props, 'initialized', false);
@@ -165,6 +165,11 @@ class BaseDriver
165
165
  return this.rawModel[methodName](methodOptions, this);
166
166
  }
167
167
 
168
+ async rawQuery(content)
169
+ {
170
+ ErrorManager.error('BaseDriver rawQuery() not implemented.');
171
+ }
172
+
168
173
  }
169
174
 
170
175
  module.exports.BaseDriver = BaseDriver;
@@ -7,7 +7,7 @@
7
7
  const { MikroOrmDriver } = require('./mikro-orm-driver');
8
8
  const { BaseDataServer } = require('../base-data-server');
9
9
  const { MikroORM } = require('@mikro-orm/core');
10
- const { Logger } = require('@reldens/utils');
10
+ const { Logger, ErrorManager } = require('@reldens/utils');
11
11
 
12
12
  class MikroOrmDataServer extends BaseDataServer
13
13
  {
@@ -64,6 +64,12 @@ class MikroOrmDataServer extends BaseDataServer
64
64
  return this.name || 'Mikro-ORM Data Server Driver';
65
65
  }
66
66
 
67
+ async rawQuery(content)
68
+ {
69
+ // @TODO - BETA - Implement.
70
+ ErrorManager.error('MikroORM rawQuery() not implemented.');
71
+ }
72
+
67
73
  }
68
74
 
69
75
  module.exports.MikroOrmDataServer = MikroOrmDataServer;
@@ -27,11 +27,22 @@ class ObjectionJsDataServer extends BaseDataServer
27
27
  if(this.initialized){
28
28
  return this.initialized;
29
29
  }
30
- // initialize knex, the query builder:
31
- this.knex = await Knex({client: this.client, connection: this.config, pool: this.poolConfig});
32
- // give the knex instance to Objection:
33
- this.rawModel.knex(this.knex);
34
- this.initialized = Date.now();
30
+ this.knex = await Knex({
31
+ client: this.client,
32
+ connection: this.config,
33
+ pool: this.poolConfig,
34
+ debug: this.debug,
35
+ multipleStatements: this.multipleStatements
36
+ });
37
+ await this.rawModel.knex(this.knex);
38
+ try {
39
+ const [[{ currentTime }]] = await this.rawModel.knex().raw(
40
+ 'SELECT ROUND(UNIX_TIMESTAMP(NOW(6)) * 1000 + MICROSECOND(NOW(6)) / 1000) AS currentTime;'
41
+ );
42
+ this.initialized = currentTime;
43
+ } catch (err) {
44
+ Logger.critical('Connection failed, Objection JS error.', err);
45
+ }
35
46
  return this.initialized;
36
47
  }
37
48
 
@@ -55,6 +66,11 @@ class ObjectionJsDataServer extends BaseDataServer
55
66
  return this.name || 'Objection JS Data Server Driver';
56
67
  }
57
68
 
69
+ async rawQuery(content)
70
+ {
71
+ return await this.knex.raw(content);
72
+ }
73
+
58
74
  }
59
75
 
60
76
  module.exports.ObjectionJsDataServer = ObjectionJsDataServer;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/storage",
3
3
  "scope": "@reldens",
4
- "version": "0.16.0",
4
+ "version": "0.18.0",
5
5
  "description": "Reldens - Storage",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",
@@ -44,9 +44,9 @@
44
44
  "url": "https://github.com/damian-pastorini/reldens-storage/issues"
45
45
  },
46
46
  "dependencies": {
47
- "@mikro-orm/core": "^5.8.10",
48
- "@mikro-orm/mongodb": "^5.8.10",
49
- "@reldens/utils": "^0.20.1",
47
+ "@mikro-orm/core": "^5.9.3",
48
+ "@mikro-orm/mongodb": "^5.9.3",
49
+ "@reldens/utils": "^0.21.0",
50
50
  "knex": "^3.0.1",
51
51
  "mysql": "^2.18.1",
52
52
  "objection": "^3.1.2"