인스타그램 클론 코딩/#2 Prisma 소개 및 설정
#2.1 Datamodel with Prisma
정중식
2019. 12. 16. 22:16
Prisma로 모델 만들기
datamodel.prisma 파일에 작성
type User {
id: ID! @id
username: String!
email: String!
firstName: String! @default(value: "")
lastName: String!
bio: String
following: [User!]! @relation(name: "FollowRelation")
followers: [User!]! @relation(name: "FollowRelation")
posts: [Post!]!
Likes: [Like!]!
comments: [Comment!]!
}
type Post {
id: ID! @id
location: String
caption: String!
user: User!
files: [File!]!
Likes: [Like!]!
comments: [Comment!]!
}
type Like {
id: ID! @id
user: User!
post: Post!
}
type Comment {
id: ID! @id
text: String!
}
type File {
id: ID! @id
url: String!
post: Post!
}
- id는 각 타입마다 한번씩 밖에 못씀
- prisma 사이트에서 user 쿼리를 username으로 바꿔줘야함