Skip to content

Commit

Permalink
Update fetchcomments.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
taedonn committed Sep 23, 2023
1 parent 4de8fee commit 716a2a4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/pages/api/user/fetchcomments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import prisma from '@/libs/client-prisma';
export async function FetchCommentsLength(user_id: number) {
const comments = await prisma.fontsComment.findMany({
select: { user_id: true },
where: { user_id: user_id }
where: {
user_id: user_id,
is_deleted: false,
is_deleted_with_reply: false,
is_deleted_by_reports: false
}
});

return comments.length;
Expand All @@ -14,7 +19,12 @@ export async function FetchCommentsLength(user_id: number) {
// SSR 첫 댓글 목록 가져오기
export async function FetchComments(user_id: number, lastId: number | undefined) {
const comments = await prisma.fontsComment.findMany({
where: { user_id: user_id },
where: {
user_id: user_id,
is_deleted: false,
is_deleted_with_reply: false,
is_deleted_by_reports: false
},
orderBy: [{created_at: 'desc'}, {comment_id: 'desc'}], // 정렬순
take: 10, // 가져오는 데이터 수
skip: lastId ? 1 : 0,
Expand Down Expand Up @@ -66,6 +76,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const length = await prisma.fontsComment.findMany({
where: {
user_id: Number(req.query.user_id),
is_deleted: false,
is_deleted_with_reply: false,
is_deleted_by_reports: false,
comment: {contains: req.query.text as string},
OR: filter
}
Expand All @@ -76,6 +89,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const comments = await prisma.fontsComment.findMany({
where: {
user_id: Number(req.query.user_id),
is_deleted: false,
is_deleted_with_reply: false,
is_deleted_by_reports: false,
comment: {contains: req.query.text as string},
OR: filter
},
Expand Down

1 comment on commit 716a2a4

@vercel
Copy link

@vercel vercel bot commented on 716a2a4 Sep 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

fonts-archive – ./

fonts-archive-git-main-taedonn.vercel.app
fonts-archive-taedonn.vercel.app
fonts.taedonn.com

Please sign in to comment.