You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I work on a prisma generator. I'm trying to solve some relationship priorities like which one is the main Model and the other one is the relationship. Let's say a User own many Posts. I would think the relationName would be "UserToPost", but with my finding, the ${from}To${to} is not depending on who own the relation, but on which Model is first in the prisma schema.
So this model would generate User.fields.posts.relationName === "UserToPost"
modelUser {idInt@id@default(autoincrement())postsPost[]}modelPost {idInt@id@default(autoincrement())authorUser@relation(fields: [authorId], references: [id])authorIdInt// relation scalar field (used in the `@relation` attribute above)}
But let's say you order your model alphabetically, the User.fields.posts.relationName === "PostToUser"
modelPost {idInt@id@default(autoincrement())authorUser@relation(fields: [authorId], references: [id])authorIdInt// relation scalar field (used in the `@relation` attribute above)}modelUser {idInt@id@default(autoincrement())postsPost[]}
It can be ambigus is the relationship is Many-to-many, but I think it would be better if the relationName would slightly be more smart ?
The text was updated successfully, but these errors were encountered:
So I work on a prisma generator. I'm trying to solve some relationship priorities like which one is the main Model and the other one is the relationship. Let's say a User own many Posts. I would think the relationName would be "UserToPost", but with my finding, the
${from}To${to}
is not depending on who own the relation, but on which Model is first in the prisma schema.So this model would generate User.fields.posts.relationName === "UserToPost"
But let's say you order your model alphabetically, the User.fields.posts.relationName === "PostToUser"
It can be ambigus is the relationship is Many-to-many, but I think it would be better if the relationName would slightly be more smart ?
The text was updated successfully, but these errors were encountered: