Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Support implicit inversed relationship #613

Closed
jiashengguo opened this issue Aug 1, 2023 · 2 comments
Closed

[Feature request] Support implicit inversed relationship #613

jiashengguo opened this issue Aug 1, 2023 · 2 comments

Comments

@jiashengguo
Copy link
Member

Support the below schema:

model User {
  id    Int    @id @default(autoincrement())
 // posts Post[].    no need to specify it in Zmodel,  ZenStack will generate it in the schema.prisma file.
}

model Post {
  id       Int  @id @default(autoincrement())
  author   User @relation(fields: [authorId], references: [id])
  authorId Int
}

Need naming convention rule to generate the inversed relation. Also, need a way to distinguish between one-to-one and one-to-many.

Take a reference of how EF handles it:
https://learn.microsoft.com/en-us/ef/core/modeling/relationships/one-to-one#one-to-one-without-navigation-to-dependent

@jmarbutt
Copy link

jmarbutt commented Aug 2, 2023

This would dramatically improve cases like this where it large schemas reference a common table like User

@ymc9
Copy link
Member

ymc9 commented Feb 23, 2024

Closing as it's covered by #430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants