I have two functions fun1() and fun2() in fun1 ,fun2 is called which returns status on which basis rest of the code works in fun1 but before fun2 return fun1 rest of the code is been executed ! Because node js is a Unblocked procedural code based one ! How to handle my case ?
async function isDuplicateUser(emailId)
{
var condition=false;
var con = mysql.createConnection({
host:"localhost",
user: "root",
password: "32577488",
database:"mydb"
});
var sql='SELECT count(*) AS namesCount FROM UserDetails WHERE emailId ="'+emailId+'";';
con.connect(function(err) {
con.query(sql, function (err, result) {
if (err){
throw err;
return ;
}
if(result[0].namesCount>=1)
{
condition=true;
console.log("Upper check :"+condition);
}
});
});
console.log("Lower check :"+condition);
return condition;
}
In logger I am seeing LowerCheck at first and then Upper check logger please help me !