query in knex js for users and password validation
<p>I want to create a query with knex js using the data from the template (using handlebars and expressjs) to validate a user. I created a query and then added it to a variable that after validate the user to login.
The point is that I am having troubles to make the knex query to do what I want it to do, and I don't know what I am doing wrong.</p>

<pre><code>    var usernameReq = req.body.username;
    var passwordReq = req.body.password;
    var pass;
    knex('users').where({
    username: usernameReq }).select('password').then(
    function(result){
        pass = result;
        }).catch(function(error) {
    console.log(error);
});

if (passwordReq === pass){
  //login  
}
</code></pre>