mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
getProjectsByOrganisationId
This commit is contained in:
@@ -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 { db } from "../client";
|
||||
|
||||
@@ -70,3 +70,13 @@ export async function getProjectWithCreatorByID(projectId: number) {
|
||||
.where(eq(Project.id, projectId));
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user