Backend: Created O2M relation between People & Media
This commit is contained in:
1 parent
1224d48c5c
commit
17067a5516
1 file changed
+17
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user