31 lines
809 B
TypeScript
31 lines
809 B
TypeScript
import { and, eq } from "drizzle-orm";
|
|
import type { AppDatabase } from "../database-context.js";
|
|
import { distributionBoards } from "../schema/distribution-boards.js";
|
|
|
|
export class DistributionBoardRepository {
|
|
constructor(private readonly database: AppDatabase) {}
|
|
|
|
async listByProject(projectId: string) {
|
|
return this.database
|
|
.select()
|
|
.from(distributionBoards)
|
|
.where(eq(distributionBoards.projectId, projectId));
|
|
}
|
|
|
|
async findById(projectId: string, distributionBoardId: string) {
|
|
return (
|
|
this.database
|
|
.select()
|
|
.from(distributionBoards)
|
|
.where(
|
|
and(
|
|
eq(distributionBoards.projectId, projectId),
|
|
eq(distributionBoards.id, distributionBoardId)
|
|
)
|
|
)
|
|
.get() ?? null
|
|
);
|
|
}
|
|
|
|
}
|