title: How to insert data in Sequelize
body: <p>In my Express app, I have to insert a new table record to MySQL database. I'm using Sequelize as the ORM. However, with the following setup , I couldn't do that. When I send a POST request to <code>/users/register</code> method(<code>UserController.signup()</code> is set to be executed at this route), it is waiting forever for a response in POSTman. I tried returning a string from <code>UserController.signup()</code> and then the request was working fine.</p>
  
  <p>Why can't I insert a record into database? Every help is highly appreciated.</p>
  
  <p><strong>UserController.js</strong></p>
  
  <pre><code>var User = require('../models/user')
  
  module.exports = {
      signUp: (fname,email,password) =&gt; {
          User.create({ firstName: fname, email: email, password: password }).then(user =&gt; {
              console.log("New auto-generated ID:", user.id);
            });
      }
  }
  </code></pre>
  
  <p><strong>models/user.js</strong></p>
  
  <pre><code>'use strict';
  module.exports = (sequelize, DataTypes) =&gt; {
    const User = sequelize.define('User', {
      firstName: DataTypes.STRING,
      email: DataTypes.STRING,
      password: DataTypes.STRING
    }, {});
    User.associate = function(models) {
      // associations can be defined here
    };
    return User;
  };
  </code></pre>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>var createError = require('http-errors');
  var express = require('express');
  var db = require('./database')
  var cookieParser = require('cookie-parser');
  var logger = require('morgan');
  
  var Router = require('./routes/index');
  
  var app = express();
  
  app.use(logger('dev'));
  app.use(express.json());
  app.use(express.urlencoded({ extended: false }));
  app.use(cookieParser());
  
  app.use(Router);
  
  db.authenticate()
  .then(() =&gt; {
    console.log('Connection has been established successfully.');
  })
  .catch(err =&gt; {
    console.error('Unable to connect to the database:', err);
  });
  
  app.use(function(req, res, next) {
    next(createError(404));
  });
  
  app.use(function(err, req, res, next) {
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};
  
    res.status(err.status || 500);
  });
  
  module.exports = app;
  </code></pre>
  
  <p><strong>database.js</strong></p>
  
  <pre><code>const Sequelize = require('sequelize');
  
  const sequelize = new Sequelize('test', 'root', '', {
    host: 'localhost',
    dialect: 'mariadb'
  });
  
  module.exports = sequelize
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I changed <code>models/user.js</code> as follows.</p>
  
  <pre><code>'use strict';
  var sequelize = require('../database')
  var Sequelize = require('sequelize')
  
  const User = sequelize.define('User', {
    firstName: Sequelize.STRING,
    email: Sequelize.STRING,
    password: Sequelize.STRING
  }, {});
  User.associate = function(models) {
    // associations can be defined here
  };
  
  module.exports = User;
  </code></pre>