i have a simple application linked up to a postgres database. it reads about 30 rows of data when you load up the application. but every now an then it wont load and when i look at my server i have the error Error: connection terminated.
usually if i load it up several times in a short space of time.
does anyone know why this might be happening? am i working it too hard?
the code is below:
function getDB(callback){
console.log('inside getDB')
Client.connect(function(err){
if(err){
return console.log('connection error', err)
}
Client.query('SELECT * FROM gallery', function(err, result){
if(err){
return console.log('error receiving data', err)
} else{
callback(null, result.rows)
}
Client.end()
})
})
}