haseakito / funbase

Next generation creators economy platform website
https://funbase.vercel.app
2 stars 0 forks source link

Hotfix `Follow` model #22

Closed haseakito closed 10 months ago

haseakito commented 10 months ago

Issue

Fix

Change the Follow model as in the suggested database model

model Follows { follower User @relation("follower", fields: [followerId], references: [id]) followerId String following User @relation("following", fields: [followingId], references: [id]) followingId String. @@id([followerId, followingId])}

haseakito commented 10 months ago

Memo

Note that when deleting follows, you have to specify the followerId and followingId in the followerId_followingId. Here is the code snippet. await prisma.follows.delete({ where: { followerId_followingId: { followerId: param.userId, followingId: session.user.id } } })