Heyo.
I've been trying to make a function return false or true, but the function doesn't load the query in time to return false or true, I'm guessing it'd probally have to be done async. but I'd just like to know your guys' opinion.
Function:
function checkUser(id){
query('SELECT * FROM `users` WHERE `id` = ' + pool.escape(id), function(error, call) {
if(error){
console.log(error);
return;
}
if(call.length <= 0){
return false;
}else{
return true;
}
});
}
Usage of the function:
if(checkUser(20)){
console.log('User exists in database!');
}else{
console.log('User does not exist!');
}
Best way to achieving my goal?