import { and, eq } from "drizzle-orm"; import type { AppDatabase } from "../database-context.js"; import { circuitLists } from "../schema/circuit-lists.js"; export class CircuitListRepository { constructor(private readonly database: AppDatabase) {} async listByProject(projectId: string) { const db = this.database; return db.select().from(circuitLists).where(eq(circuitLists.projectId, projectId)); } async findById(projectId: string, circuitListId: string) { const db = this.database; const [row] = await db .select() .from(circuitLists) .where(and(eq(circuitLists.projectId, projectId), eq(circuitLists.id, circuitListId))) .limit(1); return row ?? null; } }