title: Sequelize - Cannot read property 'define' of undefined
body: <p>I'm trying to insert a record into MYSQL table using sequelize.</p>
  
  <p>Installed sequelize and mysql.</p>
  
  <pre><code>npm install --save sequelize
  
  npm install --save mysql
  </code></pre>
  
  <p>defined it in app.js</p>
  
  <pre><code>var Sequelize = require('sequelize');
  </code></pre>
  
  <p>db.js</p>
  
  <pre><code>var Sequelize = require('sequelize');
  
  var sequelize = new Sequelize('randomdb', 'root', 'root', {
      host: 'localhost',
      dialect: 'mysql',
      port : 8889,
  
      pool: {
          max: 5,
          min: 0,
          idle: 10000
      }
  });
  
  exports.sequelize = sequelize;
  module.exports = Sequelize;
  </code></pre>
  
  <p>routes/index.js</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  var sequelize = require('../db').sequelize;
  
  /* GET home page. */
  router.get('/', function (req, res, next) {
      res.render('index', {title: 'Express'});
  });
  
  router.get('/adduser', function (req, res) {
      var User = sequelize.define('users', {
          first_name: Sequelize.STRING
      });
  
      sequelize.sync().then(function () {
          return User.create({
              first_name: 'janedoe'
          });
      }).then(function (jane) {
          console.log(jane.get({
              plain: true
          }))
      });
  });
  
  module.exports = router;
  </code></pre>
  
  <p>Here's the error.</p>
  
  <blockquote>
    <p>Cannot read property 'define' of undefined</p>
    
    <p>TypeError: Cannot read property 'define' of undefined</p>
  </blockquote>
  
  <p>What's missing?</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>db.js</p>
  
  <pre><code>var Sequelize = require('sequelize');
  
  var sequelize = new Sequelize('randomdb', 'root', 'root', {
      host: 'localhost',
      dialect: 'mysql',
      port: 8889,
  
      pool: {
          max: 5,
          min: 0,
          idle: 10000
      },
      define: {
          timestamps: false
      }
  });
  
  var db = {};
  
  db.sequelize = sequelize;
  db.Sequelize = Sequelize;
  
  module.exports = db;
  </code></pre>
  
  <p>models/user.js</p>
  
  <pre><code>var db = require('../db'),
      sequelize = db.sequelize,
      Sequelize = db.Sequelize;
  
  var User = sequelize.define('random', {
      first_name: Sequelize.STRING
  });
  
  module.exports = User;
  </code></pre>
  
  <p>routes/index.js</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  var db = require('../db'),
      sequelize = db.sequelize,
      Sequelize = db.Sequelize;
  
  var User = require('../models/user');
  
  router.get('/adduseryes', function (req, res) {
      sequelize.sync().then(function () {
          return User.create({
              first_name: 'janedoe'
          });
      }).then(function (jane) {
          res.send("YES");
      });
  });
  
  module.exports = router;
  </code></pre>