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

Commit

Permalink
docs: update many-to-many-relations.md, make it easier to understand (t…
Browse files Browse the repository at this point in the history
…ypeorm#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
  • Loading branch information
QoVoQ authored and pleerock committed Sep 5, 2019
1 parent 92e4270 commit 5bd29d5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/many-to-many-relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ export class PostToCategory {
@PrimaryGeneratedColumn()
public postToCategoryId!: number;

@Column()
public postId!: number;

@Column()
public categoryId!: number;

@Column()
Expand All @@ -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[];
```

0 comments on commit 5bd29d5

Please sign in to comment.