TypeORM-readme-31.ts
· 299 B · TypeScript
Ham
import {
Entity,
Column,
PrimaryGeneratedColumn,
OneToOne,
JoinColumn,
} from "typeorm"
import { Photo } from "./Photo"
@Entity()
export class PhotoMetadata {
/* ... other columns */
@OneToOne(() => Photo, (photo) => photo.metadata)
@JoinColumn()
photo: Photo
}
1 | import { |
2 | Entity, |
3 | Column, |
4 | PrimaryGeneratedColumn, |
5 | OneToOne, |
6 | JoinColumn, |
7 | } from "typeorm" |
8 | import { Photo } from "./Photo" |
9 | |
10 | @Entity() |
11 | export class PhotoMetadata { |
12 | /* ... other columns */ |
13 | |
14 | @OneToOne(() => Photo, (photo) => photo.metadata) |
15 | @JoinColumn() |
16 | photo: Photo |
17 | } |