knox a révisé ce gist . Aller à la révision
1 file changed, 20 insertions
TypeORM-readme-39.ts(fichier créé)
@@ -0,0 +1,20 @@ | |||
1 | + | import { | |
2 | + | Entity, | |
3 | + | Column, | |
4 | + | PrimaryGeneratedColumn, | |
5 | + | OneToMany, | |
6 | + | JoinColumn, | |
7 | + | } from "typeorm" | |
8 | + | import { Photo } from "./Photo" | |
9 | + | ||
10 | + | @Entity() | |
11 | + | export class Author { | |
12 | + | @PrimaryGeneratedColumn() | |
13 | + | id: number | |
14 | + | ||
15 | + | @Column() | |
16 | + | name: string | |
17 | + | ||
18 | + | @OneToMany(() => Photo, (photo) => photo.author) // note: we will create author property in the Photo class below | |
19 | + | photos: Photo[] | |
20 | + | } |
Plus récent
Plus ancien