I've been given access to a few databases (readonly dbs) and these dbs are in different rds servers, I have a nodejs application with typeorm and I've configured both the datasources properly as I've been able to query from each of the datasources seperately. I do not have defined entities, so i write sql in a file and read contents of the sql file. But the issue is that I query from one datasource queryrunner but the sql might have database which is in another datasource (TABLE JOINS), it only looks at the datasource from which I have made the query from. How do i join tables that are in different databases, which in turn are in different servers?
This is what I tried doing
const cronJob = new Cron("*/25 * * * * *", async () => {
const queryRunner = this.appDataSourceWareHouseDB.createQueryRunner();
const queryRunnerSAP = this.appDataSource.createQueryRunner();
try {
await queryRunner.connect();
await queryRunnerSAP.connect();
await queryRunner.startTransaction();
await queryRunnerSAP.startTransaction();
const result = await queryRunner.query(sqlQuery, [
this.lastVisitedRecordTS,
300,
this.pgrnOffset,
]);
await queryRunner.commitTransaction();
await queryRunnerSAP.commitTransaction();
Im getting a select denied for table xxx@xxxxx which is looking at the datasource from which i made the call but the table doesnt exist in that datasource.