title: Node.js express MySQL check for success
body: <p>Currently my function looks like this</p>
  
  <pre><code>module.exports.processForm = function(req, res) {
      req.assert('username', 'Username field is required').notEmpty();
      req.assert('password', 'Password field is required').notEmpty();
      if (req.validationErrors()) {
          res.render('login.html', {title: 'Login form', errors: req.validationErrors()});
      }
      db.query('SELECT name FROM users WHERE name = ? LIMIT 1', req.body.username, function(errs, data) {
          if (errs) {
              res.render('login.html', {title: 'Login form', errors: 'Wrong password / username'});
          }
      });  
  }
  </code></pre>
  
  <p>Im trying to select field name from table users but that field doesnt exists so how can I check if the query was executed successfully?
  I tried something like</p>
  
  <pre><code>if (data.length === 0) {
      res.render('login.html', {title: 'Login form', errors: 'Wrong password / username'});
  }
  </code></pre>
  
  <p>With no success, if I try to res.send(data) it looks like this <strong>[]</strong></p>