Skip to content

Commit b68426d

Browse files
committed
Typescript Bootcamp
1 parent 8b3fb62 commit b68426d

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

rest-api/src/models/course.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import {Column, CreateDateColumn, Entity,
2-
PrimaryGeneratedColumn, UpdateDateColumn} from "typeorm";
1+
import {
2+
Column, CreateDateColumn, Entity, OneToMany,
3+
PrimaryGeneratedColumn, UpdateDateColumn
4+
} from "typeorm";
5+
import {Lesson} from "./lesson";
36

47
@Entity({
58
name: "COURSES"
@@ -24,6 +27,9 @@ export class Course {
2427
@Column()
2528
category: string;
2629

30+
@OneToMany(() => Lesson, lesson => lesson.course)
31+
lessons: Lesson[];
32+
2733
@CreateDateColumn()
2834
createdAt: Date;
2935

rest-api/src/models/lesson.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn} from "typeorm";
2+
import { Course } from "./course";
3+
4+
@Entity({
5+
name: "LESSONS"
6+
})
7+
export class Lesson {
8+
9+
@PrimaryGeneratedColumn()
10+
id:number;
11+
12+
@Column()
13+
title:string;
14+
15+
@Column()
16+
duration:string;
17+
18+
@Column()
19+
seqNo: number;
20+
21+
@ManyToOne(() => Course, course => course.lessons)
22+
course: Course;
23+
24+
@CreateDateColumn()
25+
createdAt: Date;
26+
27+
@UpdateDateColumn()
28+
lastUpdatedAt: Date;
29+
}

0 commit comments

Comments
 (0)