Your code definition
this is organisation :
// This model was generated by Lumber. 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 Organisations = sequelize.define('organisations', {
name: {
type: DataTypes.STRING,
},
address: {
type: DataTypes.STRING,
},
email: {
type: DataTypes.STRING,
},
}, {
tableName: 'organisations',
timestamps: false,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Organisations.associate = (models) => {
Organisations.belongsToMany(models.medias, {
through: 'mediasOrganisations',
foreignKey: 'organisationsId',
otherKey: 'mediasId',
as: 'mediasThroughMediasOrganisations',
});
Organisations.hasMany(models.playlists, {
foreignKey: {
name: 'organisationIdKey',
field: 'organisationId',
},
as: 'playlists',
});
Organisations.hasMany(models.users, {
foreignKey: {
name: 'organisationIdKey',
field: 'organisationId',
},
as: 'users',
});
};
return Organisations;
};
this is playlist :
// This model was generated by Lumber. 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 Playlists = sequelize.define('playlists', {
name: {
type: DataTypes.STRING,
},
thumbnail: {
type: DataTypes.STRING,
},
}, {
tableName: 'playlists',
timestamps: false,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Playlists.associate = (models) => {
Playlists.belongsToMany(models.organisations, {
through: 'organisationsPlaylists',
foreignKey: 'organisationId',
as: 'organisationsThroughOrganisationsPlaylists',
});
Playlists.belongsTo(models.users, {
foreignKey: {
name: 'authorIdKey',
field: 'authorId',
},
as: 'author',
});
Playlists.belongsToMany(models.games, {
through: 'gamesPlaylists',
foreignKey: 'playlistsId',
otherKey: 'gamesId',
as: 'gamesThroughGamesPlaylists',
});
Playlists.belongsToMany(models.prosequences, {
through: 'prosequencesPlaylists',
foreignKey: 'playlistsId',
otherKey: 'prosequencesId',
as: 'prosequencesThroughProsequencesPlaylists',
});
Playlists.belongsToMany(models.sequences, {
through: 'sequencesPlaylists',
foreignKey: 'playlistsId',
otherKey: 'sequencesId',
as: 'sequencesThroughSequencesPlaylists',
});
};
return Playlists;
};
this is user :
// This model was generated by Lumber. 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 Users = sequelize.define('users', {
email: {
type: DataTypes.STRING,
},
uuid: {
type: DataTypes.STRING,
},
firstName: {
type: DataTypes.STRING,
},
lastName: {
type: DataTypes.STRING,
},
dateOfBirth: {
type: DataTypes.STRING,
},
placeOfBirth: {
type: DataTypes.STRING,
},
nationality: {
type: DataTypes.STRING,
},
address: {
type: DataTypes.STRING,
},
city: {
type: DataTypes.STRING,
},
country: {
type: DataTypes.STRING,
},
postalCode: {
type: DataTypes.STRING,
},
role: {
type: DataTypes.ENUM('user','admin','manager','pending'),
allowNull: false,
},
}, {
tableName: 'users',
timestamps: false,
});
// This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
Users.associate = (models) => {
Users.belongsToMany(models.organisations, {
through: 'organisationsUsers',
foreignKey: 'organisationId',
as: 'organisationsThroughOrganisationsUsers',
});
Users.hasMany(models.playlists, {
foreignKey: {
name: 'authorIdKey',
field: 'authorId',
},
as: 'authorPlaylists',
});
};
return Users;
};
I’m still wondering what can cause the issue. I just try on my own with a variety of relationship but couldn’t reproduce.