diff --git a/backend/config/relations.js b/backend/config/relations.js index 084ea54..ffd78a6 100644 --- a/backend/config/relations.js +++ b/backend/config/relations.js @@ -123,6 +123,23 @@ Entry.hasMany(Media, { scope: { mediaable: 'entry' } }); +// * MEDIA & People - MANY TO ONE +Media.belongsTo(People, { + foreignKey: 'mediaableId', + as: 'people', + constraints: false, + where: { + mediaable: 'people' + } +}); + +People.hasMany(Media, { + foreignKey: 'mediaableId', + constraints: false, + as: 'medias', + scope: { mediaable: 'people' } +}); + // * MEDIA & Collection - MANY TO ONE Media.belongsTo(Collection, { foreignKey: 'mediaableId',