title: Writing MySQL Node.js models using node-mysql
body: <p>I'm trying to find some good practices for writing MySQL models using <code>node-mysql</code>.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre class="lang-js prettyprint-override"><code>var client = app.settings.client; // Client is set in Express settings
  
  var table = 'users';
  
  var User = function() {
  
  }
  
  // Create the user with data from Facebook
  User.prototype.createFromFacebook = function (name, first_name, last_name, email, location, gender, facebookId, facebookToken, callback) {
    client.query(
      'INSERT INTO ' + table +
      ' SET name = ?, first_name = ?, last_name = ?, email = ?, location = ?,' +
      ' gender = ?, facebook_id = ?, facebook_token = ?',
      [ name, first_name, last_name, email, location, gender, facebookId, facebookToken ],
      function selectCb(err, results, fields) {
        if(err) {
          callback(err);
        } else {
          callback(null, results);
        }
      }
    );
  }
  
  // Get user with just their email address
  User.prototype.getByEmail = function (email, callback) {
    client.query(
      'SELECT * FROM ' + table +
      ' WHERE email = ?',
      [ email ],
      function selectCb(err, results, fields) {
        if(err) {
          callback(err);
        } else {
          callback(null, results);
        }
      }
    );
  }
  module.exports = User;
  </code></pre>
  
  <p>Any critiques or improvements on this would be awesome. Thanks!</p>