Prisma로 게시글 목록을 가져올 때 각 게시글의 작성자 정보도 필요한데, 로그 보니까 쿼리가 글 수만큼 나갑니다.
const posts = await prisma.post.findMany()
for (const post of posts) {
const author = await prisma.user.findUnique({ where: { id: post.authorId } })
}Prisma로 게시글 목록을 가져올 때 각 게시글의 작성자 정보도 필요한데, 로그 보니까 쿼리가 글 수만큼 나갑니다.
const posts = await prisma.post.findMany()
for (const post of posts) {
const author = await prisma.user.findUnique({ where: { id: post.authorId } })
}
댓글 0