Fixed errors in entity definitions

This commit is contained in:
Gerald Schmittinger 2025-02-23 14:43:02 +01:00
parent 97b5b185aa
commit 8a0a89fe45
6 changed files with 17 additions and 9 deletions

View file

@ -14,12 +14,12 @@ export class Assignment {
@Property({type: "string"}) @Property({type: "string"})
title!: string; title!: string;
@Property({type: "longtext"}) @Property({type: "text"})
description!: string; description!: string;
@ManyToOne({entity: () => LearningPath}) @ManyToOne({entity: () => LearningPath})
task!: LearningPath; task!: LearningPath;
@OneToMany({entity: () => Group}) @OneToMany({entity: () => Group, mappedBy: "assignment"})
groups!: Group[]; groups!: Group[];
} }

View file

@ -10,6 +10,6 @@ export class Group {
@PrimaryKey({type: "integer"}) @PrimaryKey({type: "integer"})
groupNumber!: number; groupNumber!: number;
@ManyToMany({entity: Student}) @ManyToMany({entity: () => Student})
members!: Student[]; members!: Student[];
} }

View file

@ -1,6 +1,7 @@
import {ManyToOne, PrimaryKey, Property} from "@mikro-orm/core"; import {Entity, ManyToOne, PrimaryKey, Property} from "@mikro-orm/core";
import {LearningObject} from "./learning-object.entity"; import {LearningObject} from "./learning-object.entity";
@Entity()
export class Attachment { export class Attachment {
@ManyToOne({entity: () => LearningObject, primary: true}) @ManyToOne({entity: () => LearningObject, primary: true})
learningObject!: LearningObject; learningObject!: LearningObject;

View file

@ -19,7 +19,7 @@ export class LearningObject {
@Property({type: "string"}) @Property({type: "string"})
title!: string; title!: string;
@Property({type: "longtext"}) @Property({type: "text"})
description!: string; description!: string;
@Property({type: "string"}) @Property({type: "string"})
@ -58,7 +58,7 @@ export class LearningObject {
@Property({type: "string", nullable: true}) @Property({type: "string", nullable: true})
contentLocation?: string; contentLocation?: string;
@OneToMany({entity: Attachment}) @OneToMany({entity: () => Attachment, mappedBy: "learningObject"})
attachments: Attachment[] = []; attachments: Attachment[] = [];
@Property({type: "blob"}) @Property({type: "blob"})

View file

@ -1,15 +1,18 @@
import {Embeddable, Embedded, Entity, Enum, OneToOne, Property} from "@mikro-orm/core"; import {Embeddable, Embedded, Entity, Enum, OneToOne, PrimaryKey, Property} from "@mikro-orm/core";
import {Language} from "./language"; import {Language} from "./language";
@Entity() @Entity()
export class LearningPath { export class LearningPath {
@Enum({items: () => Language}) @PrimaryKey({type: "string"})
hruid!: string;
@Enum({items: () => Language, primary: true})
language!: Language; language!: Language;
@Property({type: "string"}) @Property({type: "string"})
title!: string; title!: string;
@Property({type: "longtext"}) @Property({type: "text"})
description!: string; description!: string;
@Property({type: "blob"}) @Property({type: "blob"})

View file

@ -1,9 +1,13 @@
import {User} from "./user.entity"; import {User} from "./user.entity";
import {Collection, Entity, ManyToMany} from '@mikro-orm/core'; import {Collection, Entity, ManyToMany} from '@mikro-orm/core';
import {Class} from "../classes/class.entity"; import {Class} from "../classes/class.entity";
import {Group} from "../assigments/group.entity";
@Entity() @Entity()
export class Student extends User { export class Student extends User {
@ManyToMany(() => Class) @ManyToMany(() => Class)
classes!: Collection<Class>; classes!: Collection<Class>;
@ManyToMany(() => Group)
groups!: Collection<Group>;
} }