@mikro-orm/nestjs 6.0.0 → 6.0.1
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 +11 -5
- package/mikro-orm.providers.js +7 -0
- package/package.json +1 -1
package/mikro-orm-core.module.js
CHANGED
|
@@ -175,14 +175,20 @@ let MikroOrmCoreModule = MikroOrmCoreModule_1 = class MikroOrmCoreModule {
|
|
|
175
175
|
return undefined;
|
|
176
176
|
}
|
|
177
177
|
try {
|
|
178
|
+
let config;
|
|
178
179
|
if (!options || Object.keys(options).length === 0) {
|
|
179
|
-
|
|
180
|
-
return config.getDriver().createEntityManager();
|
|
180
|
+
config = await core_1.ConfigurationLoader.getConfiguration(false);
|
|
181
181
|
}
|
|
182
|
-
if ('useFactory' in options) {
|
|
183
|
-
|
|
184
|
-
return config.getDriver().createEntityManager();
|
|
182
|
+
if (!config && 'useFactory' in options) {
|
|
183
|
+
config = new core_1.Configuration(await options.useFactory(), false);
|
|
185
184
|
}
|
|
185
|
+
if (!config && options instanceof core_1.Configuration) {
|
|
186
|
+
config = options;
|
|
187
|
+
}
|
|
188
|
+
if (!config && typeof options === 'object' && options && 'driver' in options) {
|
|
189
|
+
config = new core_1.Configuration(options, false);
|
|
190
|
+
}
|
|
191
|
+
return config?.getDriver().createEntityManager();
|
|
186
192
|
}
|
|
187
193
|
catch {
|
|
188
194
|
// 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) => {
|