I need to use the Postgres temp table (only) to store temp generated data to share that data between other controllers and methods.
My app (Nest.js + Objection.js)
// app.module.ts
async onModuleInit() {
this.createVideoTempFolder();
// create temporaty table at account.repository.ts
await this.accountRepository.createAccountTempTable();
}
// account.repository.ts
public async createAccountTempTable() {
// create TEMP TABLE FOR CURRENT SESSION
const queryRaw = this.modelClass.knex();
await queryRaw.raw(`CREATE TEMPORARY TABLE accounts ON COMMIT PRESERVE ROWS as select * from accounts_main;`);
}
But my App doesn't see any temporary table at an existing connection pool. It means that every router request starts a new connection pool with Objection.js and the temporary table stays at a previously created connection pool and my App doesn't see any temporary table.
How to set up one connection pool or one connection without a connection pool to share TEMPORARY TABLE at Objection.js?