Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 1a7eda80
authored
Apr 29, 2017
by
Satvik Sharma
Committed by
Sushant
Apr 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document $nested.column$ syntax (#7581)
1 parent
0e543af0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
docs/models-usage.md
docs/models-usage.md
View file @
1a7eda8
...
...
@@ -593,6 +593,53 @@ User.findAll({
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.
### Top level where with eagerly loaded models
To move the where conditions from an included model from the
`ON`
condition to the top level
`WHERE`
you can use the
`'$nested.column$'`
syntax:
```
js
User
.
findAll
({
where
:
{
'$Instruments.name$'
:
{
$iLike
:
'%ooth%'
}
}
include
:
[{
model
:
Tool
,
as
:
'Instruments'
}]
}).
then
(
function
(
users
)
{
console
.
log
(
JSON
.
stringify
(
users
));
/*
[{
"name": "John Doe",
"id": 1,
"createdAt": "2013-03-20T20:31:45.000Z",
"updatedAt": "2013-03-20T20:31:45.000Z",
"Instruments": [{
"name": "Toothpick",
"id": 1,
"createdAt": null,
"updatedAt": null,
"userId": 1
}]
}],
[{
"name": "John Smith",
"id": 2,
"createdAt": "2013-03-20T20:31:45.000Z",
"updatedAt": "2013-03-20T20:31:45.000Z",
"Instruments": [{
"name": "Toothpick",
"id": 1,
"createdAt": null,
"updatedAt": null,
"userId": 1
}]
}],
*/
```
### Including everything
To include all attributes, you can pass a single object with
`all: true`
:
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment