22 lines
505 B
TypeScript
22 lines
505 B
TypeScript
import crypto from "node:crypto";
|
|
import { eq } from "drizzle-orm";
|
|
import { db } from "../client.js";
|
|
import { projects } from "../schema/projects.js";
|
|
|
|
export class ProjectRepository {
|
|
async list() {
|
|
return db.select().from(projects);
|
|
}
|
|
|
|
async create(name: string) {
|
|
const id = crypto.randomUUID();
|
|
await db.insert(projects).values({ id, name });
|
|
return { id, name };
|
|
}
|
|
|
|
async delete(projectId: string) {
|
|
await db.delete(projects).where(eq(projects.id, projectId));
|
|
}
|
|
}
|
|
|