不要怂,就是干,撸起袖子干!

Commit fab5349b by Sushant

[ci skip] (docs) document include.through option for Belongs-To-Many relations.

Fixes #2975 and #3416
1 parent 9203b73f
Showing with 19 additions and 6 deletions
......@@ -250,14 +250,27 @@ By default the code above will add projectId and userId to the UserProjects tabl
```js
UserProjects = sequelize.define('userProjects', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
status: DataTypes.STRING
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
status: DataTypes.STRING
})
```
With Belongs-To-Many you can query based on **through** relation and select specific attributes. For example using `findAll` with **through**
```js
User.findAll({
include: [{
model: Project,
through: {
attributes: ['createdAt', 'startedAt', 'finishedAt']
where: {completed: true}
}
}]
});
```
## Scopes
This section concerns association scopes. For a definition of association scopes vs. scopes on associated models, see [Scopes](scopes).
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!