I have table media with fields entityType and entityId - can it be relative to different tables?
For example if entityType - avatar, entityId relative to users.id, if entityType questionPreview it relative to questions.id?
r
Ryan
11/23/2020, 10:27 AM
@Bohdan Kolosovsky 👋
Have you tried creating this mapping with plain SQL? I’m not sure if it’s possible to map to different tables based on any entity directly via foreign keys.
b
Bohdan Kolosovsky
11/23/2020, 10:29 AM
It is not possible to create this mapping with plain SQL, but I did this mapping on another ORM using filter, and just asking is it possible realize it on Prisma)
r
Ryan
11/23/2020, 10:33 AM
I don’t think it is possible right now. I would suggest creating a feature request here for the same with the example from the other ORM.
b
Bohdan Kolosovsky
11/23/2020, 10:35 AM
Okay, I will create this feature ASAP, could you suggest me how to solve this problem?(my 1st msg)
r
Ryan
11/23/2020, 11:08 AM
The only workaround I think is possible is to fetch the result conditionally based on the entity type in your code itself.