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;