feat: teacher-class en teacher-students route

This commit is contained in:
Gabriellvl 2025-03-07 23:09:51 +01:00
parent 6b87722469
commit 9c9e7c4870
6 changed files with 146 additions and 21 deletions

View file

@ -1,6 +1,7 @@
import { DwengoEntityRepository } from '../dwengo-entity-repository.js';
import { Class } from '../../entities/classes/class.entity.js';
import { Student } from '../../entities/users/student.entity.js';
import {Teacher} from "../../entities/users/teacher.entity";
export class ClassRepository extends DwengoEntityRepository<Class> {
public findById(id: string): Promise<Class | null> {
@ -18,4 +19,11 @@ export class ClassRepository extends DwengoEntityRepository<Class> {
{ populate: ["students", "teachers"] } // voegt student en teacher objecten toe
)
}
public findByTeacher(teacher: Teacher): Promise<Class[]> {
return this.find(
{ teachers: teacher },
{ populate: ["students", "teachers"] }
);
}
}