I am using node Postgress and I would like to use connection pooling with it. I have simple repository like this:
Init
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
})
await pool.connect()
Example SELECT code..
export default (
{
pgPool,
}: Object
) => {
return {
getExampleData: async (uid: string) => {
const result = await pgPool.query('SELECT data FROM public.results_table WHERE uid = $1::text;', [uid])
return result.rows
},
}
}
My problem is, that under pressure (a lot of requests) I am getting the following error:
error: remaining connection slots are reserved for non-replication superuser connections
I am not sure, if I am using pool correctly.