I have a function that fetch record from postgresql asyncronously. The issue i have been trying to solve is how I can return true or false if the record fetch is greater than 0.
Here is my function:
function checkUserValidity(email){
var result = false;     
client.connect(function(err){
    if(err) {
        client.end();
        return false;
    }
    client.query("SELECT * FROM users WHERE email='" + email + "'",function(err,data){
        if(err) {
            client.end();
            return false;
        }
        result = data.rowCount > 0;
        client.end();                   
    });
}); 
return result;
}
result is always false because of promise, how can i get this done?
