I have a query that runs perfectly for a small amount of records. However if I try to run a query with a large amount of records, it does not return any output. I suspect it is because I am not properly using Async/Await.
Here is the code for my class with the exception of the actual connecting string:
sql.js
class SQL {
get connectionString() { return 'postgres://user:pass@server:port/db'; }
async queryFieldValue(query) {
const pgs = require('pg');
const R = require('rambda');
const client = new pgs.Client(this.connectionString);
await client.connect();
await client.query(query).then(res => {
const result = R.head(R.values(R.head(res.rows)));
console.log("The Result is: " + result);
}).finally(() => client.end());
}
}
export default new SQL();
Any help is appreciated =)