mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +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 { 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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user