I have some self-relation tables taken directly from one of Prisma’s examples.
model User {
id Int @id @default(autoincrement())
name String?
followedBy Follows[] @relation("follower")
following Follows[] @relation("following")
}
model Follows {
follower User @relation("follower", fields: [followerId], references: [id])
followerId Int
following User @relation("following", fields: [followingId], references: [id])
followingId Int
@@id([followerId, followingId])
}
I am wondering on the best/most idiomatic way to determine whether a user is following another user, as well as operations for following and unfollowing. I’m thinking the best way is to just query/update the Follows table directly, but I’m unsure whether the followedBy and following fields in the User model will automatically update themselves.