@reldens/storage 0.17.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.
package/lib/base-data-server.js
CHANGED
|
@@ -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);
|
package/lib/base-driver.js
CHANGED
|
@@ -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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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;
|