title: Define the order of model when use Sequelize.import
body: <p>I am now using Sequelize, a node.js orm. According to the example, I have the code as below:</p>
  
  <p>module.exports = function(callback) {</p>
  
  <pre><code>  var fs = require('fs');
    var path = require('path');
    var Sequelize = require('sequelize');
    var logger = require(path.join(__dirname, '../logger/logger.js'));
    var settings = JSON.parse(fs.readFileSync(path.join(__dirname, '../../config/settings.json'), 'utf8'));
    var dbConnectionInfo = require(path.join(__dirname, '../../lib/util/dbConnectionInfo.js'))(settings.dbUri);
    var sequelize = new Sequelize(dbConnectionInfo.dbUri,{logging:false});
  
    sequelize.authenticate()
  .then(function() {
    if (callback) {
      callback();
    }
  })
  .catch(function(error) {
    logger.error('DB Connection failed ', error);
    if (callback) {
      callback(error);
    }
  });
    var db = {};
  
    fs
  .readdirSync(__dirname)
  .filter(function(file) {
    return file.indexOf('.') !== 0 &amp;&amp; file !== 'index.js';
  })
  .forEach(function(file) {
    var model = sequelize.import(path.join(__dirname, file));
    db[model.name] = model;
  });
  
    db.sequelize = sequelize;
    return db;
  
  }
  </code></pre>
  
  <p>This code will load all the files in "model" folder. 
  The problem is that there is a model A that references model B as below shows:</p>
  
  <pre><code>var A = function(sequelize, DataTypes) {
    return sequelize.define('A', {
      serviceInstanceId: {
    type: DataTypes.STRING,
    field: 'b_id',
    allowNull: false,
    references: {
      model: B,
      key: "b_id",
      deferrable: sequelize.Deferrable.INITIALLY_IMMEDIATE
    }
  },
  
    });
      };
  </code></pre>
  
  <p>But I found that when model A is initializing, it will try to find model B, and model B now is not loaded. So is there a way that can ensure that when it try to load A , B will be load first?</p>