getProjectsByOrganisationId

This commit is contained in:
Oliver Bryan
2025-12-23 16:13:33 +00:00
parent 474a929ffa
commit 925617f493

View File

@@ -1,4 +1,4 @@
import { Issue, Project, User } from "@issue/shared"; import { Issue, Organisation, Project, User } from "@issue/shared";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import { db } from "../client"; import { db } from "../client";
@@ -70,3 +70,13 @@ export async function getProjectWithCreatorByID(projectId: number) {
.where(eq(Project.id, projectId)); .where(eq(Project.id, projectId));
return projectWithCreator; return projectWithCreator;
} }
export async function getProjectsByOrganisationId(organisationId: number) {
const projects = await db
.select()
.from(Project)
.where(eq(Project.organisationId, organisationId))
.leftJoin(User, eq(Project.creatorId, User.id))
.leftJoin(Organisation, eq(Project.organisationId, Organisation.id));
return projects;
}