Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

Commit d5fdc20

Browse files
committed
feat: define entities for typeorm
1 parent 8c157b1 commit d5fdc20

10 files changed

+125
-0
lines changed

.editorconfig

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root=true
2+
3+
[*.ts]
4+
tab_width = 2
5+
indent_size = 2
6+
indent_style = space
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true

src/entities/author.entity.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
2+
import { Podcast } from './podcast.entity';
3+
4+
@Entity()
5+
export class Author {
6+
@PrimaryGeneratedColumn()
7+
id: number;
8+
9+
@Column()
10+
name: string;
11+
12+
@OneToMany((type) => Podcast, (podcast) => podcast.author)
13+
podcasts: Podcast[];
14+
}

src/entities/author.ts

Whitespace-only changes.

src/entities/category.entity.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
2+
import { Podcast } from './podcast.entity';
3+
4+
@Entity()
5+
export class Category {
6+
@PrimaryGeneratedColumn()
7+
id: number;
8+
9+
@Column()
10+
name: string;
11+
12+
@ManyToMany((type) => Podcast, (podcast) => podcast.categories)
13+
podcasts: Podcast[];
14+
}

src/entities/category.ts

Whitespace-only changes.

src/entities/episode.entity.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
2+
import { Podcast } from './podcast.entity';
3+
4+
@Entity()
5+
export class Episode {
6+
@PrimaryGeneratedColumn()
7+
id: number;
8+
9+
@Column()
10+
title: string;
11+
12+
@Column()
13+
description: string;
14+
15+
@Column()
16+
url: string;
17+
18+
@Column()
19+
image: string;
20+
21+
@Column()
22+
type: string;
23+
24+
@Column()
25+
filesisze: number;
26+
27+
@Column()
28+
explicit: boolean;
29+
30+
@Column()
31+
guid: string;
32+
33+
@Column()
34+
duration: string;
35+
36+
@Column()
37+
publication: Date;
38+
39+
@ManyToOne((type) => Podcast, (podcast) => podcast.episodes)
40+
podcast: Podcast;
41+
}

src/entities/episode.ts

Whitespace-only changes.

src/entities/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { Author } from './author.entity';
2+
export { Category } from './category.entity';
3+
export { Episode } from './episode.entity';
4+
export { Podcast } from './podcast.entity';

src/entities/podcast.entity.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {
2+
Column,
3+
Entity,
4+
ManyToMany,
5+
ManyToOne,
6+
OneToMany,
7+
PrimaryGeneratedColumn,
8+
} from 'typeorm';
9+
import { Author } from './author.entity';
10+
import { Episode } from './episode.entity';
11+
import { Category } from './category.entity';
12+
13+
@Entity()
14+
export class Podcast {
15+
@PrimaryGeneratedColumn()
16+
id: number;
17+
18+
@Column()
19+
title: string;
20+
21+
@Column()
22+
description: string;
23+
24+
@Column()
25+
image: string;
26+
27+
@Column()
28+
language: string;
29+
30+
@Column()
31+
link: string;
32+
33+
@Column()
34+
explicit: boolean;
35+
36+
@ManyToOne((type) => Author, (author) => author.podcasts)
37+
author: Author;
38+
39+
@OneToMany((type) => Episode, (episode) => episode.podcast)
40+
episodes: Episode[];
41+
42+
@ManyToMany((type) => Category, (category) => category.podcasts)
43+
categories: Category[];
44+
}

src/entities/podcast.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)