-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
/
Post.ts
36 lines (31 loc) · 967 Bytes
/
Post.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Column, Entity, PrimaryGeneratedColumn } from "../../../src/index"
import { Author } from "./Author"
import { ManyToOne } from "../../../src/decorator/relations/ManyToOne"
import { Category } from "./Category"
import { ManyToMany } from "../../../src/decorator/relations/ManyToMany"
import { JoinTable } from "../../../src/decorator/relations/JoinTable"
import { JoinColumn } from "../../../src/decorator/relations/JoinColumn"
@Entity("sample21_post")
export class Post {
@PrimaryGeneratedColumn()
id: number
@Column()
title: string
@Column()
text: string
@ManyToOne((type) => Author, (author) => author.posts, {
cascade: true,
})
@JoinColumn({
// todo: not yet fixed
name: "user",
})
author: Author
@ManyToMany((type) => Category, (category) => category.posts, {
cascade: true,
})
@JoinTable({
name: "_post_categories",
})
categories: Category[]
}