feat: controller en service laag toegevoegd voor student/:id/classes

This commit is contained in:
Adriaan Jacquet 2025-03-04 15:50:20 +01:00
parent f5b6a5a604
commit ceef74f1af
6 changed files with 127 additions and 23 deletions

View file

@ -1,5 +1,6 @@
import { DwengoEntityRepository } from '../dwengo-entity-repository.js';
import { Class } from '../../entities/classes/class.entity.js';
import { Student } from '../../entities/users/student.entity.js';
export class ClassRepository extends DwengoEntityRepository<Class> {
public findById(id: string): Promise<Class | null> {
@ -8,4 +9,10 @@ export class ClassRepository extends DwengoEntityRepository<Class> {
public deleteById(id: string): Promise<void> {
return this.deleteWhere({ classId: id });
}
public findByStudent(student: Student): Promise<Class[]> {
return this.find(
{ students: student },
{ populate: ["students", "teachers"] } // voegt student en teacher objecten toe
)
}
}