IssueRaiser

Support for Polymorphic Associations

I have the following schema: ``` model Post { id String @default(cuid()) @id } model Comment { id String @default(cuid()) @id } model Vote { id String @default(cuid()) @id item Post | Comment } ``` I'd like to associate the `Vote` model so that a vote an be created for a `Post` or a `Comment`. As it stands now I have multiple models, `PostVote` and `CommentVote` which seems less than ideal.

Posted by piesrtasty on Feb 19, 2020, 3:03 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

support (Other)

Support for Polymorphic Associations

piesrtastyFeb 19, 2020, 3:03 AM

I have the following schema: ``` model Post { id String @default(cuid()) @id } model Comment { id String @default(cuid()) @id } model Vote { id String @default(cuid()) @id item Post | Comment } ``` I'd like to associate the `Vote` model so that a vote an be created for a `Post` or a `Comment`. As it stands now I have multiple models, `PostVote` and `CommentVote` which seems less than ideal.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue