50 lines
1020 B
TypeScript
50 lines
1020 B
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
OneToMany,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Class } from './class.entity';
|
|
import { ExamScore } from './exam-score.entity';
|
|
|
|
@Entity('exams')
|
|
export class Exam {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column({ name: 'exam_type', length: 50 })
|
|
examType: string;
|
|
|
|
@Column({ name: 'exam_name', length: 100 })
|
|
examName: string;
|
|
|
|
@Column({ length: 50 })
|
|
subject: string;
|
|
|
|
@Column({ name: 'exam_date', type: 'date' })
|
|
examDate: string;
|
|
|
|
@Column({ name: 'class_id', type: 'integer' })
|
|
classId: number;
|
|
|
|
@ManyToOne(() => Class)
|
|
@JoinColumn({ name: 'class_id' })
|
|
class: Class;
|
|
|
|
@OneToMany(() => ExamScore, (score) => score.exam)
|
|
scores: ExamScore[];
|
|
|
|
@Column({ type: 'varchar', length: 20, default: 'active' })
|
|
status: 'active' | 'archived';
|
|
|
|
@CreateDateColumn({ name: 'created_at' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at' })
|
|
updatedAt: Date;
|
|
}
|