File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ import z from "zod" ;
2+ import { CommentActionInput } from "./inputs/comment.input" ;
3+
4+ export const getComments = async (
5+ resourceId : string ,
6+ resourceType : "ARTICLE" | "COMMENT"
7+ ) => {
8+ // Fetch comments from the database based on resourceId and resourceType
9+ // const comments = await db
10+ // .select()
11+ // .from(commentsTable)
12+ // .where(commentsTable.resource_id.eq(resourceId))
13+ // .and(commentsTable.resource_type.eq(resourceType))
14+ // .orderBy(commentsTable.created_at.desc());
15+ // return comments;
16+ return [ ] ; // Placeholder for actual database query
17+ } ;
18+
19+ export const createComment = async (
20+ input : z . infer < typeof CommentActionInput . create >
21+ ) => {
22+ const { resource_id, resource_type, body } = input ;
23+
24+ // Create the comment in the database
25+
26+ // return newComment[0];
27+ } ;
28+
29+ export const deleteComment = async (
30+ input : z . infer < typeof CommentActionInput . delete >
31+ ) => {
32+ const { id } = input ;
33+
34+ // Delete the comment from the database
35+ // await db.delete(commentsTable).where(commentsTable.id.eq(id));
36+
37+ // return { success: true };
38+ } ;
Original file line number Diff line number Diff line change 1+ import z from "zod" ;
2+
3+ export const CommentActionInput = {
4+ create : z . object ( {
5+ resource_id : z . string ( ) . uuid ( ) ,
6+ resource_type : z . enum ( [ "ARTICLE" , "COMMENT" ] ) ,
7+ body : z . string ( ) . min ( 1 ) . max ( 500 ) ,
8+ } ) ,
9+ update : z . object ( {
10+ id : z . string ( ) . uuid ( ) ,
11+ body : z . string ( ) . min ( 1 ) . max ( 500 ) ,
12+ } ) ,
13+ delete : z . object ( {
14+ id : z . string ( ) . uuid ( ) ,
15+ } ) ,
16+ } ;
You can’t perform that action at this time.
0 commit comments