Description
Describe the bug
Mikro-orm v6.4 has a new feature where you can define multiple configs within mikro-orm.config.ts and then reference each one using contextName
.
This enables great synergy with their cli tool so that you can reference which context you want to use in a single config file (something like this: npx mikro-orm --contextName=super
).
When I try to set this up following their example, i get an error:
error: No driver specified, please fill in the `driver` option or use `defineConfig` helper (to define your ORM config) or `MikroORM` class (to call the `init` method) exported from the driver package (e.g. `import { defineConfig } from '@mikro-orm/mysql'; export defineConfig({ ... })`).
This problem is forcing me to have a multi config setup (aka something like mikro-orm.super.config.ts
and mikro-orm.mini.config.ts
) and makes setting up the cli less dev friendly.
To Reproduce
Steps to reproduce the behavior:
in mikro-orm.config.ts
import { defineConfig } from '@mikro-orm/postgresql';
export default [
defineConfig({
contextName: 'mini',
// other settings
}),
defineConfig({
contextName: 'super',
// other settings
}),
In app.module.ts
import mikroOrmConfigfrom "./mikro-orm.config";
MikroOrmModule.forRoot(mikroOrmConfig)
In some.service.ts
import { OnModuleInit } from "@nestjs/common";
@Injectable()
export class SomeService implements OnModuleInit {
constructor(
@InjectEntityManager("super") private readonly em: EntityManager
)
...
When I try to run my app, I get the error I posted above.
Expected behavior
Be able to have all my configs in a single file.
Dependency | Version |
---|---|
node | v20 |
typescript | 5.5 |
mikro-orm/core | 6.4 |
mikro-orm/nestjs | 6.0.2 |
your-driver | postgresql driver |
let me know if you cant reproduce this issue and it is an issue on my end. thanks!