1
I have the following relationship with the sequel
// 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 for my Tasks table to have only 2 columns with FK (ASSIGNEE and REPORTER). The problem is that the sequelize creates these columns, but creates a userid as well.
It is possible to make this relationship between the same models with 2 different columns?