我在两个表之间有很多关系:
type Post {
id: ID! @id
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
name: String!
users: [Profile!] @relation(link: TABLE, name: "ParticipatedUsers")
}
type Profile {
id: ID! @id
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
name: String!
participatingInPosts: [Post!] @relation(name: "ParticipatedUsers")
}
type ParticipatedUsers @relationTable {
post: Post
profile: Profile
requiredPostsCount: Int
publishedPostsCount: Int
}
并且在尝试运行命令pyramida deploy时,出现以下错误:
错误:
参与的用户link链接表不得指定任何其他标量字段。link链接表不得指定任何其他标量字段。link链接表不得指定任何其他标量字段。
我如何创建关系表并向该表添加新字段?
谢谢,
在Prisma中,您可以通过添加具有标量字段和要连接的类型两个关系的类型来进行此操作,例如:
type Post {
id: ID! @id
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
name: String!
users: [ParticipatedUser!] @relation(link: TABLE, name: "ParticipatedUserPosts")
}
type Profile {
id: ID! @id
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
name: String!
participatingInPosts: [ParticipatedUser!] @relation(link: TABLE, name: "ParticipatedUserProfiles")
}
type ParticipatedUser {
post: Post! @relation(name: "ParticipatedUserPosts")
profile: Profile! @relation(name: "ParticipatedUserProfiles")
requiredPostsCount: Int
publishedPostsCount: Int
}