Skip to content

Commit

Permalink
docs(association): document uniqueKey for belongs to many (#12166)
Browse files Browse the repository at this point in the history
  • Loading branch information
sushantdhiman committed Apr 25, 2020
1 parent 55678d2 commit 2e032e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/manual/core-concepts/assocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ CREATE TABLE IF NOT EXISTS "ActorMovies" (

Unlike One-To-One and One-To-Many relationships, the defaults for both `ON UPDATE` and `ON DELETE` are `CASCADE` for Many-To-Many relationships.

Belongs-To-Many creates a unique key when primary key is not present on through model. This unique key name can be overridden using **uniqueKey** option.

```js
Project.belongsToMany(User, { through: UserProjects, uniqueKey: 'my_custom_unique' })
```

## Basics of queries involving associations

With the basics of defining associations covered, we can look at queries involving associations. The most common queries on this matter are the *read* queries (i.e. SELECTs). Later on, other types of queries will be shown.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"semantic-release": "^17.0.7",
"sinon": "^9.0.2",
"sinon-chai": "^3.3.0",
"sqlite3": "^4.0.6",
"sqlite3": "^4.1.1",
"tedious": "6.0.0",
"typescript": "^3.6.3"
},
Expand Down

0 comments on commit 2e032e0

Please sign in to comment.