Replies: 5 comments 4 replies
-
I am not sure how could we integrate this (unless we provide driver specific exports in the nest package too), but this is surely worth documenting. |
Beta Was this translation helpful? Give feedback.
-
Yup, probably driver specific export would be an overkill for the nest package 😄 |
Beta Was this translation helpful? Give feedback.
-
Maybe we could at least simplify this - all we need to know is the driver in use, from there we can infer everything. So instead of wrapping everything explicitly, we could just let the user pass in the driver in a separate option next to the MikroOrmModule.forRootAsync({
useFactory: (configService: ConfigService) => configService.getOrThrow(ConfigKey.ORM),
inject: [ConfigService],
driver: PostgreSqlDriver,
}) Then we can create the driver instance and the EM out of it. I also wanted to add public methods to the platform level to expose the |
Beta Was this translation helpful? Give feedback.
-
For the user, adding such a parameter could be quite simple, as well as the implementation itself. I'm definitely in favor. |
Beta Was this translation helpful? Give feedback.
-
does this mean we cannot use |
Beta Was this translation helpful? Give feedback.
-
When registering
MikroOrmModule
using forRootAsync together with useFactory function, which contains at least one injection parameter, onlyMikroORM
andEntityManager
are registered only from'@mikro-orm/core'
package.I think there is no way, how this could be done automatically in MikroOrmModule.forRootAsync in that case, but I came up with very simple solution - create alias module, which can user register manually:
E.g.: mikro-orm-alias.module.ts for
'@mikro-orm/postgresql'
specific driverAnd than using in Root module:
Than driver specific injection in services works fine:
I am thinking about, if it probably could be somehow embedded into MikroOrm, so user imports and registers driver specific alias module, so driver specific injection will work.
Or probably it could be mentioned somewhere in documentation?
Beta Was this translation helpful? Give feedback.
All reactions