Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
HUNG-rushb committed Dec 23, 2023
1 parent 200e04d commit c7b947f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Type_Definitions/Comment_Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const commentDefs = gql`
deleteComment(data: DeleteCommentInput!): Comment!
updateComment(data: UpdateCommentInput!): Comment!
voteComment(data: VoteCommentInput!): Comment!
deleteAllComment: DeleteAllReturnType!
}
extend type Query {
Expand Down
2 changes: 1 addition & 1 deletion src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ model Comment {
cmt_to_user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
postId String? @db.ObjectId
cmt_to_post Post? @relation(fields: [postId], references: [id], onDelete: Cascade, onUpdate: Cascade)
cmt_to_post Post? @relation(fields: [postId], references: [id])
storyId String? @db.ObjectId
cmt_to_story Story? @relation(fields: [storyId], references: [id], onDelete: Cascade, onUpdate: Cascade)
Expand Down
11 changes: 11 additions & 0 deletions src/resolvers/Mutation/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ const commentMutation = {
throw Error('Action should be UPVOTE, DOWNVOTE, CANCEL');
}
},
deleteAllComment: async (parent, args, info) => {
let result;
try {
result = await prisma.comment.deleteMany({});
} catch (e) {
console.log(e);
throw e;
}

return result;
},
};

export default commentMutation;

0 comments on commit c7b947f

Please sign in to comment.