Thank you, I got it finally working. :)
const {
Client
} = require('pg')
const client = new Client({
user: 'USER',
host: 'HOST',
database: 'DB',
password: 'PW',
port: 5432,
})
async function beforeRender(req, res, done) {
client.connect()
const result = await client.query({
text: 'SELECT column FROM table'
})
console.log(result.rowCount)
Object.assign(req.data, {
elements: result.rows
})
done();
}