인스타그램 데이터 모델 작성
type User {
id: ID! @id
avatar: String
userName: String! @unique
email: String! @unique
firstName: String @default(value: "")
lastName: String
bio: String
followers: [User!]! @relation(name: "FollowRelation")
following: [User!]! @relation(name: "FollowRelation")
posts: [Post!]! @relation(name: "PostsOfUser", onDelete: CASCADE)
likes: [Like!]! @relation(name: "LikesOfUser", onDelete: CASCADE)
comments: [Comment!]! @relation(name: "CommentsOfUser", onDelete: CASCADE)
rooms: [Room!]!
loginSecret: String
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
type Post {
id: ID! @id
location: String
caption: String!
user: User @relation(name: "PostsOfUser")
files: [File!]! @relation(name: "FilesOfPost", onDelete: CASCADE)
likes: [Like!]! @relation(name: "LikeOfPost", onDelete: CASCADE)
comments: [Comment!]! @relation(name: "CommentOfPost", onDelete: CASCADE)
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
type Like {
id: ID! @id
user: User @relation(name: "LikesOfUser")
post: Post @relation(name: "LikeOfPost")
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
type Comment {
id: ID! @id
text: String!
user: User @relation(name: "CommentsOfUser")
post: Post @relation(name: "CommentOfPost")
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
type File {
id: ID! @id
url: String!
post: Post @relation(name: "FilesOfPost")
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
type Room {
id: ID! @id
participants: [User!]!
messages: [Message!]!
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
type Message {
id: ID! @id
text: String!
from: User! @relation(name: "From")
to: User! @relation(name: "To")
room: Room!
createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}
'미분류' 카테고리의 다른 글
Hooks + Apollo 초기 세팅 (0) | 2019.07.31 |
---|---|
prisma 알게 된 것들 (0) | 2019.07.30 |
GraphQL 초기 프로젝트 설정 (0) | 2019.07.30 |