model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
password String
bio String?
avatar String?
followers User[] @relation("FollowRelation", references: [id])
following User[] @relation("FollowRelation", references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
photos Photo[]
likes Like[]
comments Comment[]
}
model Photo {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
file String
caption String?
hashtags Hashtag[]
likes Like[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
comments Comment[]
}
model Hashtag {
id Int @id @default(autoincrement())
hashtag String @unique
photos Photo[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Like {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
photo Photo @relation(fields: [photoId], references: [id])
user User @relation(fields: [userId], references: [id])
photoId Int
userId Int
@@unique([photoId, userId])
}
model Comment {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
photo Photo @relation(fields: [photoId], references: [id])
payload String
userId Int
photoId Int
}
check!!
1. model Comment 확인!!
2. model User와 model Photo에서 Comment와의 relation확인할 것
import { gql } from 'apollo-server'
export default gql`
type Comment {
id: Int!
createdAt: String!
updatedAt: String!
user: User!
phoho: Photo!
payload: String!
isMine: Boolean!
}
`
import prisma from "../client"
export default {
Comment: {
isMine: ({ userId }, _, { loggedInUser }) => {
if (!loggedInUser) {
return false
}
return userId === loggedInUser.id
},
user: ({ userId }) => prisma.user.findUnique({ where: { id: userId } }),
},
}
import { gql } from 'apollo-server'
export default gql`
type CreateCommentResult {
ok: Boolean!
error: String
}
type Mutation {
createComment(photoId: Int!, payload: String!): CreateCommentResult!
}
`
check!! photoId를 arg로 받는 거 확인할 것!!!
payload는 댓글 내용!!
import prisma from '../../client'
import { protectedResolver } from '../../users/users.util'
export default {
Mutation: {
createComment: protectedResolver(
async (_, { photoId, payload }, { loggedInUser }) => {
const ok = await prisma.photo.findUnique({
where: { id: photoId },
select: { id: true },
})
if (!ok) {
return {
ok: false,
error: 'Photo not found',
}
}
await prisma.comment.create({
data: {
payload,
photo: {
connect: { id: photoId },
},
user: {
connect: { id: loggedInUser.id },
},
},
})
return {
ok: true,
}
}
),
},
}
check!!
await prisma.comment.create에서 photo와 user를 connect 해 주는 부분 확인할 것!!
Drift Boss is a famous drifting game. In the game, you will have the opportunity to control your car on endless roads full of difficult turns and collisions. The game sounds simple but it takes a lot of practice to be able to drift well around corners. Join the game now to prove that you are the best racer and score the most points.
Welcome to the obvious escorts benefit in your goliath city Delhi. We have gotten as Delhi Call Young women. A call young woman is known essentially to meet one's sexual necessities or basics.
https://www.sanakhan.in/katwaria-sarai-call-girls.html
https://www.sanakhan.in/karkardooma-call-girls.html
https://www.sanakhan.in/hari-nagar-call-girls.html
https://www.sanakhan.in/jorhipur-call-girls.html
https://www.sanakhan.in/hauz-khas-call-girl.html
Whether you are looking to ship goods across the state or across the country, there are plenty of freight transport providers in Michigan that can help. Here are some of the key players in the industry and the services they offer: https://www.youtube.com/watch?v=kvWcrsP1iQ0
The information you share is excellent and exciting, and thanks to that, I know more valuable things. Keep posting interesting things and I will keep an eye on your posts https://busd-store.com/
The largest call girls cash payment are standing by to welcome you with amiable conversations and attractive looks. There will be many girls for you to pick from. There are many different types of nearby escort girls, including young, aged, MILF, breasts, skinny, curvy, Indian, Russian, and more.
https://sheetaldubay.com/jalandhar-call-girls4/
https://sheetaldubay.com/call-girl-in-amritsar4/
https://sheetaldubay.com/escort-navi-mumbai4/
https://sheetaldubay.com/chennai-call-girls4/
https://sheetaldubay.com/call-girls-hyderabad4/
https://sheetaldubay.com/kolkata-call-girls4/
https://sheetaldubay.com/call-girl-bangalore4/
I was impressed by your writing. Your writing is impressive. I want to write like you.I hope you can read my post and let me know what to modify. My writing is in I would like you to visit my blog.
https://www.gfnyt.com/call-girls/telangana/hyderabad/
https://www.gfnyt.com/call-girls/rajasthan/jaipur/
https://www.gfnyt.com/call-girls/west-bengal/kolkata/
https://www.gfnyt.com/call-girls/uttar-pradesh/lucknow/
https://www.gfnyt.com/call-girls/maharashtra/mumbai/
https://www.gfnyt.com/call-girls/maharashtra/pune/
Thanks for sharing your article
https://www.medixocentre.com/
https://www.heptopic.com/
https://indiangenericprice.com/
https://abirateroneacetatecost.com/
Gracias por compartir tu articulo!
https://www.bonitofarmacia.com/
https://www.bonitofarmacia.com/sofosbuvir-sovaldi-precio-republica-dominicana
https://www.medixocentre.com/zoladex-acetato-de-goserelina-precio
https://abirateroneacetatecost.com/enzalutamida-xtandi-precio-mexico
https://abirateroneacetatecost.com/enzalutamida-xtandi-precio-chile
Gracias por compartir tu articulo!
https://www.bonitofarmacia.com/
https://www.bonitofarmacia.com/sofosbuvir-sovaldi-precio-republica-dominicana
https://www.medixocentre.com/zoladex-acetato-de-goserelina-precio
https://abirateroneacetatecost.com/enzalutamida-xtandi-precio-mexico
https://abirateroneacetatecost.com/enzalutamida-xtandi-precio-chile
https://www.escortserviceindia.in/call-girls/gurgaon
https://www.escortserviceindia.in/
https://www.escortserviceindia.in/escorts/sainik-colony
https://www.escortserviceindia.in/call-girls/ram-nagar
https://www.escortserviceindia.in/blog/delhi/near-me/call-girls/pushpanjali-farms
https://www.escortserviceindia.in/escorts/feroz-gandhi-colony
https://www.escortserviceindia.in/escorts/sikrod
Writing curl commands can be a hassle, so I developed a tool to generate them easily. https://doramasmp4.com.mx/
https://ct.mayabansal.net/shillong-escort-agency
https://ct.mayabansal.net/mysore-escort-agency
https://ct.mayabansal.net/himatnagar-escort
https://ct.mayabansal.net/chennai-escort-agency
https://ct.mayabansal.net/visakhapatnam-escort-agency
https://ct.mayabansal.net/coimbatore-escort-agency
https://ct.mayabansal.net/thiruvananthapuram-escort-agency
https://ct.mayabansal.net/gwalior-escort-agency
https://ct.mayabansal.net/mangalore-escort-agency
Your writing is truly inspiring! I'm eager to elevate my own skills. Could you please offer feedback on my latest blog post? I've linked it below.
https://majnulaila.com/call-girl-in-jaipur/
https://majnulaila.com/call-girl-in-bangalore/
https://majnulaila.com/call-girl-in-dehradun/
The information you share is excellent and exciting, and thanks to that, I know more valuable things. Keep posting interesting things and I will keep an eye on your posts. krunker