Expected behavior
The column which links to a record on another table using relationships should have the clickable values for each associated record, like in this example from the Live demo:
Actual behavior
The problem I’m having is that the value is loaded only after the record is clicked:
How my table looks when I load it:
The mcc column is a belongsTo relationship with a record on another table
After I click to open the first line:
The linked record shows as it’s supposed to, and so goes if I click the other records. But everything goes blank again if I refresh the page
Context
This is my accounts model (the table on the pictures)
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
const Accounts = sequelize.define('accounts', {
id : {type : DataTypes.UUID, primaryKey:true},
account_id : DataTypes.STRING,
mcc_id : DataTypes.STRING,
name : DataTypes.STRING,
medium : DataTypes.ENUM(['googleads','bingads']),
platform : DataTypes.ENUM(['hotmart','eduzz','monetizze','other']),
status : DataTypes.ENUM(['active', 'ready', 'full', 'suspended', 'canceled']),
number : DataTypes.INTEGER
}, {
tableName: 'accounts',
underscored: true,
schema: process.env.DATABASE_SCHEMA,
});
Accounts.associate = (models) => {
Accounts.belongsTo(models.mccs, {foreignKey: 'mcc_id', targetKey: 'mcc_id', as: 'mcc'});
};
return Accounts;
};
This is my mccs model (the linked table):
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
const Mccs = sequelize.define('mccs', {
id: { type: DataTypes.UUID, primaryKey: true },
name: DataTypes.STRING,
mcc_id: DataTypes.STRING,
medium: DataTypes.ENUM(['googleads', 'bingads']),
status: DataTypes.ENUM(['active', 'ready', 'full', 'suspended', 'canceled'])
}, {
tableName: 'mccs',
underscored: true,
schema: process.env.DATABASE_SCHEMA,
});
Mccs.associate = (models) => {
Mccs.hasMany(models.accounts, { sourceKey: 'mcc_id', foreignKey: 'mcc_id', as: 'accounts' });
};
return Mccs;};
This behavior is happening in all the relationships in my database, not only in this one.
Thanks