I am trying to add data to my databases. There are multiple entries in an array
dataArryay.forEach((element) => {
queryData(elementData)
}
The function is called multiple times
async function queryData(data) {
const queryString = `INSERT............')`;
const query = {
text: queryString
};
const pool = await new pg.Pool({
host: 'localhost',
port: 'xxxx',
user: 'xxxxxx',
database: 'xxxxx',
max: 100,
idleTimeoutMillis: 50000,
connectionTimeoutMillis: 3000,
});
await pool.connect();
await pool.query(query)
await pool.end()
}
It does the insert but it does throw the too many connections error. I have tried .release() and .end()
When querying the connections I get
max_conn = 500
used = 6
res_for_super = 3
res_for_normal = 491
I don't really know what these men but they seem to add up to 500.