NestJS + TypeORM: Use two or more databases?

前端 未结 3 1449
野性不改
野性不改 2020-12-31 09:03

I\'m trying since 2 days to solve this, perhaps I\'m simply missing the point here.

My goal was to write a NestJS app (with TypeORM included) which serves a RestAPI

3条回答
  •  猫巷女王i
    2020-12-31 09:14

    You need to explicitly pass the connection name at the same level inside TypeOrmModule.forRoot({ name: 'db1Connection' }) incase you are using multiple database connections.

    TypeOrmModule.forRootAsync({
      name: DB1_CONNECTION,
      imports: [ConfigModule],
      useClass: TypeormDb1ConfigService,
    }),
    
    TypeOrmModule.forRootAsync({
      name: DB2_CONNECTION,
      imports: [ConfigModule],
      useClass: TypeormDb2ConfigService,
    })
    

提交回复
热议问题