title: importing model as function, sequelize fixtures not import data from json file: Unhandled rejection Error return?
body: <p>In my node js project I am using express and sequelize. I would like to create some fixtures in order to populate my data tables.</p>
  
  <p>Using <a href="https://www.npmjs.com/package/sequelize-fixtures-fixed" rel="nofollow">Sequelize-fixtures</a> npm, this is my <code>fixtures.js</code> file:</p>
  
  <pre><code>'use strict';
  
  const sequelize_fixtures = require('sequelize-fixtures');
  
  // define all the model
  const models = {
              Mission: require(__dirname+'/../models/mission.js')
          };
  
  var fixtures =[
      {
          "model": "Mission",
          "data": {
              "description": "mission test 1",
              "state": "pending",
              "slug" : "mission-test-1"
          }
      },
      {
          "model": "Mission",
          "data": {
              "description": "mission test 2",
              "state": "finished",
              "slug" : "mission-test-2"
          }
      }
  ];
  // export and load fixtures
  module.exports = {
      loadFixtures: () =&gt; {
          // can use glob syntax to select multiple files
          sequelize_fixtures.loadFixtures(fixtures, models).then(function(){
              console.log("Fixtures have been loaded, check your database tables ;) !!!");
          });
      }
  };
  </code></pre>
  
  <p>In the root of my project I call this module like this in <code>server.js</code> :</p>
  
  <pre><code>// ...
  // Importing sequelize
  let database = require(__dirname + '/database/database');
  let fixturesLoader = require(__dirname+'/database/fixtures/fixtures.js');
  </code></pre>
  
  <p>But I have this error now in my console when I restart the node server:</p>
  
  <blockquote>
    <p>Unhandled rejection Error: models.Mission appears to be a function.
    Perhaps you are importing model factory function? You should then use
    sequelize.import to create your model, see
    <a href="https://github.com/sequelize/express-example/blob/master/models/index.js#L17" rel="nofollow">https://github.com/sequelize/express-example/blob/master/models/index.js#L17</a></p>
  </blockquote>
  
  <p>Of course I check the link, and this is how I use sequelize and the configuration in a file named database.js:</p>
  
  <pre><code>'use strict';
  
  const fs        = require('fs');
  const path      = require('path');
  const Sequelize = require('sequelize');
  const config    = require(__dirname+'/database.json');
  const db        = {};
  
  let sequelize = new Sequelize(config.db.dbname, config.db.user, config.db.password, {
      host: config.db.host,
      port: config.db.port,
      define: {
          // And deletedAt to be called destroyTime (remember to enable paranoid for this to work)
          deletedAt: 'deleted_at',
          paranoid: true,
          // don't use camelcase for automatically added attributes but underscore style
          underscored: true,
          // disable the modification of table names; By default, sequelize will automatically
          // transform all passed model names (first parameter of define) into plural.
          freezeTableName: true,
          charset: 'utf8',
          collate: 'utf8_general_ci',
          timestamps: true,
          language: 'fr'
      }
  });
  
  fs.readdirSync(__dirname + '/models').filter(function (file) {
      return (file.indexOf('.') !== 0);
  }).forEach(function (file) {
      let model = sequelize.import(path.join(__dirname + '/models', file));
      db[model.name] = model;
  });
  
  Object.keys(db).forEach(function (modelName) {
      if ('associate' in db[modelName]) {
          db[modelName].associate(db);
      }
  });
  
  db.sequelize = sequelize;
  db.Sequelize = Sequelize;
  
  module.exports = db;
  </code></pre>
  
  <p>I understand that I am importing my model as function, but following the doc, I don't understand how to import them without this way.</p>