title: called with something that's not an instance of Sequelize.Model at Model.belongsTo
body: <p>I'm trying to refer a foreign key between 2 models.</p>
  
  <p>but I'm getting this error:</p>
  
  <pre><code>throw new Error(this.name + '.' + Utils.lowercaseFirst(Type.toString()) + ' called with something that\'s not an instance of Sequelize.Model');
  called with something that's not an instance of Sequelize.Model
      at Model.belongsTo
  </code></pre>
  
  <p>How can I fix this?</p>
  
  <p>This is my code so far.</p>
  
  <p>This is my models/mercadolibre.js</p>
  
  <pre><code>"use strict";
  var User  = require('../models/index').User;
  
  module.exports = function(sequelize, DataTypes) {
    var MercadoLibre = sequelize.define("MercadoLibre", {
      id:  { 
            type: DataTypes.INTEGER, 
            autoIncrement: true, 
            primaryKey: true
          },
      access_token: DataTypes.STRING,
      refresh_token: DataTypes.STRING,
      environment_hash: DataTypes.STRING 
    }, {
      tableName: 'mercadolibres',
      underscored: true,
      timestamps: true
    }
  
    );
  
    MercadoLibre.belongsTo(User);
  
    return MercadoLibre;
  };
  </code></pre>
  
  <p>This is my models/user.js</p>
  
  <pre><code>"use strict";
  
  module.exports = function(sequelize, DataTypes) {
    var User = sequelize.define("User", {
      id:  { 
            type: DataTypes.INTEGER, 
            autoIncrement: true, 
            primaryKey: true
          },
      name: DataTypes.STRING,
      slack_id: DataTypes.STRING,
      environment_hash: {
            type: DataTypes.STRING,
            defaultValue: DataTypes.UUIDV4
          }
    }, {
      tableName: 'users',
      underscored: false,
      timestamps: false
    }
  
    );
  
    return User;
  };
  </code></pre>
  
  <p>This is my models/index.js</p>
  
  <pre><code>"use strict";
  
  var fs        = require("fs");
  var path      = require("path");
  var Sequelize = require('sequelize')
    , sequelize = new Sequelize(process.env.MYSQL_DB, process.env.MYSQL_USER, process.env.MYSQL_PASSWORD, {
        dialect: "mysql", // or 'sqlite', 'postgres', 'mariadb'
        port:    3306, // or 5432 (for postgres)
  });
  
  
  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;
    });
  
  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>