多对多关系prisma 2

时间:2021-03-04 22:20:53

标签: prisma prisma2

我正在尝试实现一个关注取消关注功能。我正在使用prisma 2,但我在如何更新以下数组方面遇到困难。

我的架构:

model User {
  id         Int     @id @default(autoincrement())
  email      String  @unique
  password   String
  username   String
  bio        String?
  image      String?
  posts      Post[]
  followedBy User[]  @relation("UserFollows")
  following  User[]  @relation("UserFollows")
}

我的路线:

await prisma.user.update({
  where: {
    id: userLogged,
  },
  data: {
    following: {
      connect: { id: id },
    },
  },
});

0 个答案:

没有答案
相关问题