mythix 2.7.0 → 2.7.2
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/package.json +2 -2
- package/src/models/model-module.js +1 -1
- package/src/models/model-utils.js +2 -17
- package/src/models/model.js +3 -2
- package/src/utils/test-utils.js +14 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mythix",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "Mythix is a NodeJS web-app framework",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"form-data": "^4.0.0",
|
|
36
36
|
"luxon": "^3.0.4",
|
|
37
37
|
"micromatch": "^4.0.5",
|
|
38
|
-
"mythix-orm": "^1.8.
|
|
38
|
+
"mythix-orm": "^1.8.1",
|
|
39
39
|
"nife": "^1.12.1",
|
|
40
40
|
"prompts": "^2.4.2"
|
|
41
41
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { Types
|
|
3
|
+
const { Types } = require('mythix-orm');
|
|
4
4
|
const { Model: ModelBase } = require('./model');
|
|
5
5
|
|
|
6
|
-
function _setupModel(modelName, _Model, { application
|
|
6
|
+
function _setupModel(modelName, _Model, { application }) {
|
|
7
7
|
let Model = _Model;
|
|
8
8
|
let tableName = Model.getTableName();
|
|
9
9
|
let tablePrefix = application.getDBTablePrefix();
|
|
@@ -14,21 +14,6 @@ function _setupModel(modelName, _Model, { application, connection: applicationCo
|
|
|
14
14
|
Model.getTableName = () => tableName;
|
|
15
15
|
Model.getModelName = () => modelName;
|
|
16
16
|
Model.getApplication = () => application;
|
|
17
|
-
Model.getLogger = () => application.getLogger();
|
|
18
|
-
Model._getConnection = (_connection) => {
|
|
19
|
-
if (_connection)
|
|
20
|
-
return _connection;
|
|
21
|
-
|
|
22
|
-
let { connection } = Model.getModelContext();
|
|
23
|
-
if (connection)
|
|
24
|
-
return connection;
|
|
25
|
-
|
|
26
|
-
connection = Utils.getContextValue('connection');
|
|
27
|
-
if (connection)
|
|
28
|
-
return connection;
|
|
29
|
-
|
|
30
|
-
return applicationConnection;
|
|
31
|
-
};
|
|
32
17
|
|
|
33
18
|
return { [modelName]: Model };
|
|
34
19
|
}
|
package/src/models/model.js
CHANGED
|
@@ -48,11 +48,12 @@ class Model extends _Model {
|
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
static _getConnection(_connection) {
|
|
52
|
+
let connection = _Model._getConnection(_connection);
|
|
52
53
|
if (connection)
|
|
53
54
|
return connection;
|
|
54
55
|
|
|
55
|
-
return this.getDBConnection();
|
|
56
|
+
return this.getApplication().getDBConnection();
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
package/src/utils/test-utils.js
CHANGED
|
@@ -64,18 +64,6 @@ function createTestApplication(ApplicationClass) {
|
|
|
64
64
|
return defaultModules;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
createDatabaseConnection() {
|
|
68
|
-
const NOOP = () => {};
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
isStarted: () => true,
|
|
72
|
-
start: NOOP,
|
|
73
|
-
stop: NOOP,
|
|
74
|
-
registerModels: NOOP,
|
|
75
|
-
getModels: () => ({}),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
67
|
constructor(_opts) {
|
|
80
68
|
let opts = Nife.extend(true, {
|
|
81
69
|
environment: 'test',
|
|
@@ -97,6 +85,20 @@ function createTestApplication(ApplicationClass) {
|
|
|
97
85
|
value: new HTTPInterface(),
|
|
98
86
|
},
|
|
99
87
|
});
|
|
88
|
+
|
|
89
|
+
if (!this.createDatabaseConnection) {
|
|
90
|
+
this.createDatabaseConnection = (function createDatabaseConnection() {
|
|
91
|
+
const NOOP = () => {};
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
isStarted: () => true,
|
|
95
|
+
start: NOOP,
|
|
96
|
+
stop: NOOP,
|
|
97
|
+
registerModels: NOOP,
|
|
98
|
+
getModels: () => ({}),
|
|
99
|
+
};
|
|
100
|
+
}).bind(this);
|
|
101
|
+
}
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
getTestingLoggerConfig(loggerOpts) {
|