Backend: Created O2M relation between People & Media

This commit is contained in:
X4Lo committed 2025-07-12 00:42:08 +01:00
1 parent 1224d48c5c
commit 17067a5516
1 file changed
+17
+17
View File
@@ -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',