@mikro-orm/nestjs 6.0.0 → 6.0.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/mikro-orm-core.module.js +12 -5
- package/mikro-orm.providers.js +7 -0
- package/package.json +4 -4
package/mikro-orm-core.module.js
CHANGED
|
@@ -152,6 +152,7 @@ let MikroOrmCoreModule = MikroOrmCoreModule_1 = class MikroOrmCoreModule {
|
|
|
152
152
|
...(options.providers || []),
|
|
153
153
|
...(0, mikro_orm_providers_1.createAsyncProviders)({ ...options, contextName: options.contextName }),
|
|
154
154
|
(0, mikro_orm_providers_1.createMikroOrmProvider)(contextName),
|
|
155
|
+
...(mongo ? [(0, mikro_orm_providers_1.createMikroOrmProvider)(contextName, mongo.MikroORM)] : []),
|
|
155
156
|
(0, mikro_orm_providers_1.createEntityManagerProvider)(options.scope, core_1.EntityManager, contextName),
|
|
156
157
|
...(em ? [(0, mikro_orm_providers_1.createEntityManagerProvider)(options?.scope, em.constructor, contextName)] : []),
|
|
157
158
|
...(knex ? [(0, mikro_orm_providers_1.createEntityManagerProvider)(options?.scope, knex.EntityManager, contextName)] : []),
|
|
@@ -175,14 +176,20 @@ let MikroOrmCoreModule = MikroOrmCoreModule_1 = class MikroOrmCoreModule {
|
|
|
175
176
|
return undefined;
|
|
176
177
|
}
|
|
177
178
|
try {
|
|
179
|
+
let config;
|
|
178
180
|
if (!options || Object.keys(options).length === 0) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
config = await core_1.ConfigurationLoader.getConfiguration(false);
|
|
182
|
+
}
|
|
183
|
+
if (!config && 'useFactory' in options) {
|
|
184
|
+
config = new core_1.Configuration(await options.useFactory(), false);
|
|
185
|
+
}
|
|
186
|
+
if (!config && options instanceof core_1.Configuration) {
|
|
187
|
+
config = options;
|
|
181
188
|
}
|
|
182
|
-
if ('
|
|
183
|
-
|
|
184
|
-
return config.getDriver().createEntityManager();
|
|
189
|
+
if (!config && typeof options === 'object' && options && 'driver' in options) {
|
|
190
|
+
config = new core_1.Configuration(options, false);
|
|
185
191
|
}
|
|
192
|
+
return config?.getDriver().createEntityManager();
|
|
186
193
|
}
|
|
187
194
|
catch {
|
|
188
195
|
// ignore
|
package/mikro-orm.providers.js
CHANGED
|
@@ -6,6 +6,13 @@ const mikro_orm_common_1 = require("./mikro-orm.common");
|
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const mikro_orm_entities_storage_1 = require("./mikro-orm.entities.storage");
|
|
8
8
|
function createMikroOrmProvider(contextName, type = core_1.MikroORM) {
|
|
9
|
+
if (!contextName && type !== core_1.MikroORM) {
|
|
10
|
+
return {
|
|
11
|
+
provide: type,
|
|
12
|
+
useFactory: orm => orm, // just a simple alias
|
|
13
|
+
inject: [core_1.MikroORM], // depend on the ORM from core package
|
|
14
|
+
};
|
|
15
|
+
}
|
|
9
16
|
return {
|
|
10
17
|
provide: contextName ? (0, mikro_orm_common_1.getMikroORMToken)(contextName) : type,
|
|
11
18
|
useFactory: async (options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/nestjs",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Martin Adamek",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"lint": "eslint src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@mikro-orm/core": "^6.0.0",
|
|
43
|
+
"@mikro-orm/core": "^6.0.0 || ^6.0.0-dev.0",
|
|
44
44
|
"@nestjs/common": "^10.0.0",
|
|
45
45
|
"@nestjs/core": "^10.0.0"
|
|
46
46
|
},
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@types/jest": "^29.5.12",
|
|
55
55
|
"@types/node": "^20.12.12",
|
|
56
56
|
"@types/supertest": "^6.0.2",
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "~7.
|
|
58
|
-
"@typescript-eslint/parser": "~7.
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "~7.12.0",
|
|
58
|
+
"@typescript-eslint/parser": "~7.12.0",
|
|
59
59
|
"conventional-changelog": "^6.0.0",
|
|
60
60
|
"conventional-changelog-cli": "^5.0.0",
|
|
61
61
|
"eslint": "^8.57.0",
|