Implementing Exercise system in database with API and frontend visualization
This commit is contained in:
33
software/backend/models/exercises/exercise.model.ts
Normal file
33
software/backend/models/exercises/exercise.model.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { BelongsTo, Column, ForeignKey, Model, Table } from "sequelize-typescript";
|
||||
import { ExerciseGroup } from "./exerciseGroup.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class Exercise extends Model {
|
||||
@Column
|
||||
nameDe: String
|
||||
|
||||
@Column
|
||||
nameEn: String
|
||||
|
||||
@Column
|
||||
exerciseNr: Number
|
||||
|
||||
@Column
|
||||
descriptionDe: String
|
||||
|
||||
@Column
|
||||
descriptionEn: String
|
||||
|
||||
@Column
|
||||
solved: Boolean
|
||||
|
||||
@ForeignKey(() => ExerciseGroup)
|
||||
@Column
|
||||
exerciseGroupId: Number
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@BelongsTo(() => ExerciseGroup)
|
||||
exerciseGroup: ExerciseGroup
|
||||
}
|
||||
20
software/backend/models/exercises/exerciseGroup.model.ts
Normal file
20
software/backend/models/exercises/exerciseGroup.model.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Column, HasMany, Model, Table } from "sequelize-typescript";
|
||||
import { Exercise } from "./exercise.model";
|
||||
|
||||
@Table({ timestamps: false })
|
||||
export class ExerciseGroup extends Model {
|
||||
@Column
|
||||
nameDe: String
|
||||
|
||||
@Column
|
||||
nameEn: String
|
||||
|
||||
@Column
|
||||
groupNr: Number
|
||||
|
||||
|
||||
// Relations
|
||||
|
||||
@HasMany(() => Exercise)
|
||||
exercises: Exercise[]
|
||||
}
|
||||
Reference in New Issue
Block a user