I am using node-postgres (https://node-postgres.com/) pool in my project.
I some case I need to process insert operation in for loop, like this:
data.forEach(items => {
pgPool.query('INSERT INTO cache (hash, data) VALUES($1::text, $2::json)', [key, JSON.stringify(items)])
})
I think that it's not a good way how to multiple query insert.
Is there any better way?
For example pgPool.multipleQuery(queryArray) ?
Or is my solution correct?
Thank you for any help.