I did a test on your architecture. And with theses three models it work fine IMO.
// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const Org = sequelize.define('org', {
name: {
type: DataTypes.STRING,
},
}, {
tableName: 'org',
timestamps: false,
schema: process.env.DATABASE_SCHEMA,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Org.associate = (models) => {
Org.belongsToMany(models.dep, {
through: 'orgDep',
foreignKey: 'orgId',
otherKey: 'depId',
as: 'depThroughOrgDeps',
});
};
return Org;
};
// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const Dep = sequelize.define('dep', {
name: {
type: DataTypes.STRING,
},
}, {
tableName: 'dep',
timestamps: false,
schema: process.env.DATABASE_SCHEMA,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Dep.associate = (models) => {
Dep.belongsToMany(models.org, {
through: 'orgDep',
foreignKey: 'depId',
otherKey: 'orgId',
as: 'orgThroughOrgDeps',
});
};
return Dep;
};
// This model was generated by Forest CLI. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const OrgDep = sequelize.define('orgDep', {}, {
tableName: 'orgDep',
timestamps: false,
schema: process.env.DATABASE_SCHEMA,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
OrgDep.associate = (models) => {
OrgDep.belongsTo(models.dep, {
foreignKey: {
name: 'depIdKey',
field: 'depId',
},
as: 'dep',
});
OrgDep.belongsTo(models.org, {
foreignKey: {
name: 'orgIdKey',
field: 'orgId',
},
as: 'org',
});
};
return OrgDep;
};
After that you can go to your layout editor and hide all id fields as below
let me know if that help