Ignace Mella
03/31/2022, 9:34 AMmodel User {
id Int @id @default(autoincrement())
name String?
followedBy User[] @relation("UserFollows", references: [id])
following User[] @relation("UserFollows", references: [id])
}
Hi people, I found this part on the documentation, but I don't really get how I can just simply let a User follow and unfollow a User. What does the code have to look like?Austin
03/31/2022, 8:49 PMconnect
and disconnect
APIs to do so. Here’s an example of unfollowing a given user:
await prisma.user.update({
where: { id: someUserId },
data: {
following: {
disconnect: {
id: userIdToUnfollow
}
}
}
})
This will “unrelate” a given user, removing it from a user’s following
list.
You can read more in our docs, but let me know if you have more questions!