Skip to content

Commit

Permalink
docs: fix bidirectional association examples in v7 upgrade guide
Browse files Browse the repository at this point in the history
  • Loading branch information
medgardo authored Aug 25, 2023
1 parent 5bb3340 commit f30c78f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/other-topics/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,14 @@ This lead to subtle bugs, so starting with v7, associations options must perfect
For instance, the following declaration is no longer valid:

```typescript
User.belongsToMany(Countries, { foreignKey: 'user_id' });
Countries.belongsToMany(User);
User.belongsToMany(Country, { foreignKey: 'user_id' });
Country.belongsToMany(User);
```

But this is:

```typescript
User.belongsToMany(User, { foreignKey: 'user_id' });
User.belongsToMany(Country, { foreignKey: 'user_id' });
Country.belongsToMany(User, { otherKey: 'user_id' });
```

Expand All @@ -315,15 +315,15 @@ Instead of writing this:

```typescript
User.belongsToMany(Country, { as: 'countries' });
User.belongsToMany(User, { as: 'citizen' });
Country.belongsToMany(User, { as: 'citizens' });
```

You can now write this:

```typescript
User.belongsToMany(Country, {
as: 'countries',
inverse: { as: 'citizen' },
inverse: { as: 'citizens' },
});
```

Expand Down

0 comments on commit f30c78f

Please sign in to comment.