I'm using MySQL in ExpressJS. I've inserted data in my database and now I need to authenticate the user with the data present in the database, e.g.:
username: john
password: 123
Now when ever john logs in with the username and password it should check whether it is present in MySQL or not as I've a little bit background in PHP in which we use the following approach:
$query=mysql_query("SELECT * from login WHERE username='".$_POST['username']."' AND password='".$_POST['password']."' ") or die(mysql_error());
if(mysql_fetch_row($query)>0){
echo "Login Sucessfully";
}>
else{
echo "Wrong Id or Password";
}
Have a look at the auth example from express' github page. It'll take some time to understand, especially if you're not used to asynchronous programming - but this example should do.
This example uses no database at all, but you can try to implement an my-sql database using @felixge's mysql module.