I'm using a variable inside the nested function and after assigning a value pass to the parent function but on calling it shows nothing.
function userexists(key) {
  let user = false;
  UsersModel.findOne({ email: key }, function (error, foundUser) {
    if (!error && foundUser) user = foundUser;
    else {
      console.log("error or not found: " + error);
    }
  });
  return user;
}
 
    