Skip to content

Support for Polymorphic Associations #1644

@piesrtasty

Description

@piesrtasty

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions