title: How to create relationship between two tables using feathersjs, sequelize and postgresql
body: <p>I have two models <strong>users.model.js</strong> and <strong>swing-trades.model.js</strong> when I am creating a relationship between these two models and running feathersjs using npm run dev`, I am getting an error.</p>
  <blockquote>
  <p>throw new Error(<code>${this.name}.hasMany called with something that's not a subclass of Sequelize.Model</code>);
  ^</p>
  <p>Error: users.hasMany called with something that's not a subclass of
  Sequelize.Mode</p>
  </blockquote>
  <pre><code>**users.model.js**
  
  // See http://docs.sequelizejs.com/en/latest/docs/models-definition/
  // for more of what you can do here.
  const Sequelize = require('sequelize');
  const DataTypes = Sequelize.DataTypes;
  
  module.exports = function (app) {
    const sequelizeClient = app.get('sequelizeClient');
    const users = sequelizeClient.define('users', {
  
      email: {
        type: DataTypes.STRING,
        allowNull: true,
        unique: true
      },
      password: {
        type: DataTypes.STRING,
        allowNull: true
      },
      username: {
        type: DataTypes.STRING,
        allowNull: true,
      },
      firstName: {
        type: DataTypes.STRING,
        allowNull: true,
      },
      lastName: {
        type: DataTypes.STRING,
        allowNull: true,
      }
    },
    {
      timestamps: true, // Enable timestamps
      createdAt: true, // Don't create createdAt
      updatedAt: true, // Don't create updatedAt
      // eslint-disable-next-line no-dupe-keys
      updatedAt: 'updateTimestamp', // updatedAt should be called updateTimestamp
    },
    {
      hooks: {
        beforeCount(options) {
          options.raw = true;
        }
      }
    });
  
    // eslint-disable-next-line no-unused-vars
    users.associate = function (models) {
      // Define associations here
      // See http://docs.sequelizejs.com/en/latest/docs/associations/
      const {swingTrades} = models;
  
      users.hasMany(swingTrades, {as: 'swingTrades', foreignKey: 'userId'}); // will add userid to swingtrades model
    };
  
    return users;
  };
  </code></pre>
  <p><strong><code>swing-trades.model.js</code></strong></p>
  <pre><code>// See http://docs.sequelizejs.com/en/latest/docs/models-definition/
  // for more of what you can do here.
  const Sequelize = require('sequelize');
  const DataTypes = Sequelize.DataTypes;
  
  module.exports = function (app) {
    const sequelizeClient = app.get('sequelizeClient');
    const swingTrades = sequelizeClient.define('swing_trades', {
      company: {
        type: DataTypes.STRING,
        allowNull: true
      }
    },
    {
      timestamps: true, // Enable timestamps
      createdAt: false, // Don't create createdAt
      updatedAt: false, // Don't create updatedAt
      // eslint-disable-next-line no-dupe-keys
      updatedAt: 'updateTimestamp', // updatedAt should be called updateTimestamp
    },
    {
      hooks: {
        beforeCount(options) {
          options.raw = true;
        }
      }
    });
  
    // eslint-disable-next-line no-unused-vars
    swingTrades.associate = function (models) {
      // Define associations here
      // See http://docs.sequelizejs.com/en/latest/docs/associations/
      const {users} = models;
  
      swingTrades.belongsTo(users,{foreignKey: 'userId'});
      
    };
  
    return swingTrades;
  };
  </code></pre>
  <p>I have not found any solutions for this.</p>