Files
graff-mate-server/src/services/comments/getComments.ts
T
2025-06-20 12:13:46 +05:00

32 lines
802 B
TypeScript

import { status } from "elysia";
import { and, desc, eq } from "drizzle-orm";
import db from "../../db";
import { commentsTable } from "../../db/schema";
export async function getComments(sessionId: string, managerId: string) {
try {
const comments = await db.query.commentsTable.findMany({
where: and(
eq(commentsTable.sessionId, sessionId),
eq(commentsTable.managerId, managerId)
),
with: {
manager: {
columns: {
fullname: true,
id: true,
},
},
session: true,
},
orderBy: desc(commentsTable.createdAt),
});
return comments;
} catch (error) {
console.log((error as Error).message);
return status(500, "Internal Server Error");
}
}
export default getComments;