I'm learning about pg-promise. My question is very simple. I want to create a function return true if it found a result. but it kept returning false because of async. Could someone give me a comprehensive advice how to handle the beast (async)??
function find(id){
var found = false;
db.one("select * from users where id=$1", id) // find the user from id;
.then(function(data){
console.log(data);
found = true;
}, function(reason){
console.log(reason); // display reason why the call failed;
})
return found;
}