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

Commit 0f3143b7 by Bulkan Evcimen

Explain include.required implicitly set

* When include.where is used
1 parent 3219a9c0
Showing with 5 additions and 1 deletions
...@@ -1075,7 +1075,8 @@ User.findAll({ include: [{ model: Tool, as: 'Instruments' }] }).then(function(us ...@@ -1075,7 +1075,8 @@ User.findAll({ include: [{ model: Tool, as: 'Instruments' }] }).then(function(us
}) })
``` ```
When eager loading we can also filter the associated model using `where` When eager loading we can also filter the associated model using `where`. This will return all
`User`s in which the `where` clause of `Tool` model matches rows.
```js ```js
User.findAll({ include: [{ model: Tool, as: 'Instruments', where: {name: {$like: '%ooth%'}} }] }) User.findAll({ include: [{ model: Tool, as: 'Instruments', where: {name: {$like: '%ooth%'}} }] })
...@@ -1115,6 +1116,9 @@ User.findAll({ include: [{ model: Tool, as: 'Instruments', where: {name: {$like: ...@@ -1115,6 +1116,9 @@ User.findAll({ include: [{ model: Tool, as: 'Instruments', where: {name: {$like:
}) })
``` ```
When an eager loaded model is filtered using `include.where` then `include.required` is implicitly set to
`true`. This means that an inner join is done returning parent models with any matching children.
### Including everything ### Including everything
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!