import { eq } from "drizzle-orm"; import { db } from "../config/database.js"; import { exams, type Exam, type NewExam } from "./exams.schema.js"; export class ExamsRepository { async findById(id: string): Promise { const [result] = await db .select() .from(exams) .where(eq(exams.id, id)) .limit(1); return result; } async findByClassId(classId: string): Promise { return db.select().from(exams).where(eq(exams.classId, classId)); } async update(id: string, data: Partial): Promise { await db.update(exams).set(data).where(eq(exams.id, id)); } async delete(id: string): Promise { await db.delete(exams).where(eq(exams.id, id)); } } export const examsRepository = new ExamsRepository();