I have the following relation with the sequelize
// Tasks.js
sequelize.models.tasks.belongsTo(sequelize.models.users, {
foreignKey: {
type: DataTypes.INTEGER,
field: 'ASSIGNEE',
allowNull: true
},
as: 'assignee'
});
sequelize.models.tasks.belongsTo(sequelize.models.users, {
foreignKey: {
type: DataTypes.INTEGER,
field: 'REPORTER',
allowNull: true
},
as: 'reporter'
});
// Users.js
sequelize.models.users.hasMany(sequelize.models.tasks, { as: 'assignee' });
sequelize.models.users.hasMany(sequelize.models.tasks, { as: 'reporter' });
However, what I need is that, in my Tasks table, I only have 2 columns with FK (ASSIGNEE and REPORTER). The problem is that sequelize creates these columns, but creates a 'userId' as well.
Is it possible to do this relationship between the same models with 2 different columns?