From 7ec5500299a81dd3ff553e1a247a6552e0d425dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me> Date: Tue, 23 Jan 2024 18:13:06 +0100 Subject: [PATCH] ExerciseManager => Add function to get all exercises of an assignment --- ExpressAPI/src/managers/ExerciseManager.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ExpressAPI/src/managers/ExerciseManager.ts b/ExpressAPI/src/managers/ExerciseManager.ts index 95bc487..66cfda8 100644 --- a/ExpressAPI/src/managers/ExerciseManager.ts +++ b/ExpressAPI/src/managers/ExerciseManager.ts @@ -12,6 +12,15 @@ class ExerciseManager { include: include }) as unknown as Exercise ?? undefined; } + + async getFromAssignment(assignmentName: string, include: Prisma.ExerciseInclude | undefined = undefined): Promise<Array<Exercise> | undefined> { + return await db.exercise.findMany({ + where : { + assignmentName: assignmentName + }, + include: include + }) as Array<Exercise> ?? undefined; + } } -- GitLab