fix(backend): Update MikroORM, Fix voor 'pks not iterable' problem in Groups
This commit is contained in:
parent
451ac7546f
commit
9c638b11f6
5 changed files with 57 additions and 53 deletions
|
@ -16,11 +16,11 @@
|
|||
"test:unit": "vitest --run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mikro-orm/core": "6.4.9",
|
||||
"@mikro-orm/knex": "6.4.9",
|
||||
"@mikro-orm/postgresql": "6.4.9",
|
||||
"@mikro-orm/reflection": "6.4.9",
|
||||
"@mikro-orm/sqlite": "6.4.9",
|
||||
"@mikro-orm/core": "6.4.12",
|
||||
"@mikro-orm/knex": "6.4.12",
|
||||
"@mikro-orm/postgresql": "6.4.12",
|
||||
"@mikro-orm/reflection": "6.4.12",
|
||||
"@mikro-orm/sqlite": "6.4.12",
|
||||
"axios": "^1.8.2",
|
||||
"cors": "^2.8.5",
|
||||
"cross": "^1.0.0",
|
||||
|
@ -43,7 +43,7 @@
|
|||
"winston-loki": "^6.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mikro-orm/cli": "6.4.9",
|
||||
"@mikro-orm/cli": "6.4.12",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/express": "^5.0.0",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
|
|
|
@ -35,5 +35,5 @@ export class Assignment {
|
|||
entity: () => Group,
|
||||
mappedBy: 'assignment',
|
||||
})
|
||||
groups!: Collection<Group>;
|
||||
groups: Collection<Group> = new Collection<Group>(this);
|
||||
}
|
||||
|
|
|
@ -7,15 +7,19 @@ import { GroupRepository } from '../../data/assignments/group-repository.js';
|
|||
repository: () => GroupRepository,
|
||||
})
|
||||
export class Group {
|
||||
@ManyToOne({
|
||||
entity: () => Assignment,
|
||||
primary: true,
|
||||
})
|
||||
assignment!: Assignment;
|
||||
|
||||
/*
|
||||
WARNING: Don't move the definition of groupNumber! If it does not come before the definition of assignment,
|
||||
creating groups fails because of a MikroORM bug!
|
||||
*/
|
||||
@PrimaryKey({ type: 'integer', autoincrement: true })
|
||||
groupNumber?: number;
|
||||
|
||||
@ManyToOne({
|
||||
entity: () => Assignment,
|
||||
primary: true
|
||||
})
|
||||
assignment!: Assignment;
|
||||
|
||||
@ManyToMany({
|
||||
entity: () => Student,
|
||||
owner: true,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Group } from '../entities/assignments/group.entity.js';
|
||||
import { Class } from '../entities/classes/class.entity.js';
|
||||
import { mapToAssignmentDTO } from './assignment.js';
|
||||
import {mapToAssignmentDTOId} from './assignment.js';
|
||||
import { mapToClassDTO } from './class.js';
|
||||
import { mapToStudentDTO } from './student.js';
|
||||
import { GroupDTO } from '@dwengo-1/common/interfaces/group';
|
||||
|
@ -8,7 +8,7 @@ import { GroupDTO } from '@dwengo-1/common/interfaces/group';
|
|||
export function mapToGroupDTO(group: Group, cls: Class): GroupDTO {
|
||||
return {
|
||||
class: mapToClassDTO(cls),
|
||||
assignment: mapToAssignmentDTO(group.assignment),
|
||||
assignment: mapToAssignmentDTOId(group.assignment),
|
||||
groupNumber: group.groupNumber!,
|
||||
members: group.members.map(mapToStudentDTO),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue