TypeORM-readme-39.ts
· 391 B · TypeScript
Raw
import {
Entity,
Column,
PrimaryGeneratedColumn,
OneToMany,
JoinColumn,
} from "typeorm"
import { Photo } from "./Photo"
@Entity()
export class Author {
@PrimaryGeneratedColumn()
id: number
@Column()
name: string
@OneToMany(() => Photo, (photo) => photo.author) // note: we will create author property in the Photo class below
photos: Photo[]
}
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 | } |