MCPcopy Create free account
hub / github.com/Hazrat-Ali9/Problem-Solving-Frontend / getCommentByPostId

Function getCommentByPostId

lib/firebase/comment.ts:43–62  ·  view source on GitHub ↗
(postId: string)

Source from the content-addressed store, hash-verified

41}
42
43export async function getCommentByPostId(postId: string): Promise<any> {
44 try {
45 const commentRef = collection(db, COMMENTS);
46 const q = query(commentRef, where("pid", "==", postId));
47 const querySnapshot = await getDocs(q);
48
49 if (querySnapshot.empty) {
50 throw new Error("No comments found for this post.");
51 }
52
53 const comments = querySnapshot.docs.map((doc) => ({
54 id: doc.id,
55 ...doc.data(),
56 }));
57 return comments;
58 } catch (error) {
59 console.error("Error fetching comments:", error);
60 throw error;
61 }
62}
63const getSingleComment = async (commentId: string): Promise<any> => {
64 try {
65 const docRef = doc(db, COMMENTS, commentId);

Callers 1

CommentSectionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected