import { desc, eq } from "drizzle-orm"; import type { AppDatabase } from "../database-context.js"; import { externalExportBatches } from "../schema/external-export-batches.js"; export class ExternalExportBatchRepository { constructor(private readonly database: AppDatabase) {} append(batch: typeof externalExportBatches.$inferInsert) { this.database.insert(externalExportBatches).values(batch).run(); return batch; } listByProject(projectId: string) { return this.database.select().from(externalExportBatches) .where(eq(externalExportBatches.projectId, projectId)) .orderBy(desc(externalExportBatches.exportedAtIso), desc(externalExportBatches.id)).all(); } }