Closed pxr64 closed 5 years ago
I'm having a similar error. Using multiple connections work fine until I want to use TypeOrm entity-features (so anything other than raw .query
's). As soon as I include:
imports: [
TypeOrmModule.forFeature([MyEntity], 'connection2'),
],
in the relevant module, Nest returns the error 'Nest can't resolve dependencies of the connection2Connection_MyEntityRepository (?)'.
Changing the positon of the name
property does not work. BTW: I'm not using ormconfig.json
, but:
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({...})
});
TIA.
Using the second connection works as intended when using TypeOrmModule.forRoot()
and supplying the connection values hardcoded.
Duplicate of https://github.com/nestjs/typeorm/issues/66
Came up with this workaround to create two connections from ormconfig.json
TypeOrmModule.forRootAsync({name: 'secondConnection', useFactory: () => {
const options = new ConnectionOptionsReader().all();
return options.then(opts => {
return opts[0]
});
}})
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Bug Report
Current behaviour
I have the following ormconfig.json:
And the following configuration iside my modules.
On startupt I get the following error:
Nest can't resolve dependencies of the employees_AddressRepository (?).
Expected behavior
Nest should initialise without any issues and should be able to access the databases.
Update
I think it has something to do with the
name
property of the connection.I've tried to setup my connection via
forRootAsync
and I get the same error when I set the connection name in the async block. My code below.