26 lines
765 B
TypeScript
26 lines
765 B
TypeScript
import { asc, eq } from "drizzle-orm";
|
|
import type { AppDatabase } from "../database-context.js";
|
|
import { circuits } from "../schema/circuits.js";
|
|
|
|
export class CircuitRepository {
|
|
constructor(private readonly database: AppDatabase) {}
|
|
|
|
async listByCircuitList(circuitListId: string) {
|
|
const db = this.database;
|
|
return db
|
|
.select()
|
|
.from(circuits)
|
|
.where(eq(circuits.circuitListId, circuitListId))
|
|
.orderBy(asc(circuits.sortOrder), asc(circuits.equipmentIdentifier));
|
|
}
|
|
|
|
async listBySection(sectionId: string) {
|
|
const db = this.database;
|
|
return db
|
|
.select()
|
|
.from(circuits)
|
|
.where(eq(circuits.sectionId, sectionId))
|
|
.orderBy(asc(circuits.sortOrder), asc(circuits.equipmentIdentifier));
|
|
}
|
|
}
|