express-typescript-boilerplate icon indicating copy to clipboard operation
express-typescript-boilerplate copied to clipboard

Question: Is there a way to support multiple databases with single connection?

Open AhmedMasoodSiddiqui opened this issue 6 years ago • 1 comments

Is there a way to connect to multiple databases using a single or multiple connection? typeorm docs suggests there is and it works with simple node project, but i cant configure it in this project. I have changed the single connection from typeormLoader.ts to array.

AhmedMasoodSiddiqui avatar Aug 21 '19 15:08 AhmedMasoodSiddiqui

According to TypeORM docs, you can either use multiple connections by passing an array to the createConnection method, or in case you want to work with just one connection check:

https://typeorm.io/#/multiple-connections/using-multiple-databases-in-a-single-connection

You'll have to specify which database you want to connect and work with in your entities, and very likely in some other places as you keep adding business logic into your Services and Repositories.

carlosHowmie avatar Oct 08 '19 07:10 carlosHowmie