Skip to content
This repository was archived by the owner on Mar 18, 2022. It is now read-only.

Commit 5bd29d5

Browse files
QoVoQpleerock
authored andcommitted
docs: update many-to-many-relations.md, make it easier to understand (typeorm#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
1 parent 92e4270 commit 5bd29d5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

docs/many-to-many-relations.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ export class PostToCategory {
186186
@PrimaryGeneratedColumn()
187187
public postToCategoryId!: number;
188188

189+
@Column()
189190
public postId!: number;
191+
192+
@Column()
190193
public categoryId!: number;
191194

192195
@Column()
@@ -203,6 +206,13 @@ export class PostToCategory {
203206
Additionally you will have to add a relationship like the following to `Post` and `Category`:
204207

205208
```typescript
209+
// category.ts
210+
...
211+
@OneToMany((type) => PostToCategory, (postToCategory) => postToCategory.category)
212+
public postToCategories!: PostToCategory[];
213+
214+
// post.ts
215+
...
206216
@OneToMany((type) => PostToCategory, (postToCategory) => postToCategory.post)
207217
public postToCategories!: PostToCategory[];
208218
```

0 commit comments

Comments
 (0)