Using Multiple Fields for a Unique Key in Prisma
I encountered an issue with Prisma that took up some of my time, so I wanted to share how I resolved it. In my model, I didn’t have an id field marked with @id, so I added @@unique() to define the user and tweet fields as a unique constraint. model Like { user Int tweet Int createdAt DateTime @default(now()) @@unique([user, tweet]) } This means that we cannot have duplicate entries with the same (user, tweet) combination....