From 5bd29d58c3422beab0018f973bd59e1f7695c7d2 Mon Sep 17 00:00:00 2001 From: QoVoQ <674263588@qq.com> Date: Thu, 5 Sep 2019 20:27:30 +0800 Subject: [PATCH] docs: update many-to-many-relations.md, make it easier to understand (#4680) * Update many-to-many-relations.md Make the example of the last section `many-to-many relations with custom properties` more clear and general. * Update many-to-many-relations.md --- docs/many-to-many-relations.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/many-to-many-relations.md b/docs/many-to-many-relations.md index 1ade4bd27b..e066fd1b75 100644 --- a/docs/many-to-many-relations.md +++ b/docs/many-to-many-relations.md @@ -186,7 +186,10 @@ export class PostToCategory { @PrimaryGeneratedColumn() public postToCategoryId!: number; + @Column() public postId!: number; + + @Column() public categoryId!: number; @Column() @@ -203,6 +206,13 @@ export class PostToCategory { Additionally you will have to add a relationship like the following to `Post` and `Category`: ```typescript +// category.ts +... +@OneToMany((type) => PostToCategory, (postToCategory) => postToCategory.category) +public postToCategories!: PostToCategory[]; + +// post.ts +... @OneToMany((type) => PostToCategory, (postToCategory) => postToCategory.post) public postToCategories!: PostToCategory[]; ```