knox 修订了这个 Gist . 跳至此修订
1 file changed, 20 insertions
TypeORM-readme-39.ts(file created)
@@ -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 | + | } |
更新
更早