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 6c9a76dc
authored
Mar 04, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize child include build performance
1 parent
c0c3fadb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
18 deletions
changelog.md
lib/dao.js
changelog.md
View file @
6c9a76d
Notice: All 1.7.x changes are present in 2.0.x aswell
Notice: All 1.7.x changes are present in 2.0.x aswell
# v2.0.0-dev10
# v2.0.0-dev10
-
[
PERFORMANCE
]
increased build performance when using include, which speeds up findAll etc.
#### Backwards compatability changes
#### Backwards compatability changes
-
selectedValues has been removed for performance reasons, if you depend on this, please open an issue and we will help you work around it.
-
selectedValues has been removed for performance reasons, if you depend on this, please open an issue and we will help you work around it.
-
foreign keys will now correctly be based on the alias of the model
-
foreign keys will now correctly be based on the alias of the model
...
...
lib/dao.js
View file @
6c9a76d
...
@@ -220,9 +220,13 @@ module.exports = (function() {
...
@@ -220,9 +220,13 @@ module.exports = (function() {
})
})
var
association
=
include
.
association
var
association
=
include
.
association
,
self
=
this
,
self
=
this
,
accessor
=
Utils
.
_
.
camelize
(
key
)
,
childOptions
,
primaryKeyAttribute
=
include
.
daoFactory
.
primaryKeyAttribute
,
isEmpty
=
value
[
0
]
&&
value
[
0
][
primaryKeyAttribute
]
===
null
var
accessor
=
Utils
.
_
.
camelize
(
key
)
if
(
!
isEmpty
)
{
var
childOptions
=
{
childOptions
=
{
isNewRecord
:
false
,
isNewRecord
:
false
,
isDirty
:
false
,
isDirty
:
false
,
include
:
include
.
include
,
include
:
include
.
include
,
...
@@ -231,29 +235,17 @@ module.exports = (function() {
...
@@ -231,29 +235,17 @@ module.exports = (function() {
includeValidated
:
true
,
includeValidated
:
true
,
raw
:
options
.
raw
raw
:
options
.
raw
}
}
}
// downcase the first char
// downcase the first char
accessor
=
accessor
.
slice
(
0
,
1
).
toLowerCase
()
+
accessor
.
slice
(
1
)
accessor
=
accessor
.
slice
(
0
,
1
).
toLowerCase
()
+
accessor
.
slice
(
1
)
value
.
forEach
(
function
(
data
)
{
var
daoInstance
=
include
.
daoFactory
.
build
(
data
,
childOptions
)
,
isEmpty
=
!
Utils
.
firstValueOfHash
(
daoInstance
.
identifiers
)
if
(
association
.
isSingleAssociation
)
{
if
(
association
.
isSingleAssociation
)
{
accessor
=
Utils
.
singularize
(
accessor
,
self
.
sequelize
.
language
)
accessor
=
Utils
.
singularize
(
accessor
,
self
.
Model
.
options
.
language
)
self
.
dataValues
[
accessor
]
=
isEmpty
?
null
:
daoInstance
self
[
accessor
]
=
self
.
dataValues
[
accessor
]
=
isEmpty
?
null
:
include
.
daoFactory
.
build
(
value
[
0
],
childOptions
)
self
[
accessor
]
=
self
.
dataValues
[
accessor
]
}
else
{
}
else
{
if
(
!
self
.
dataValues
[
accessor
])
{
self
[
accessor
]
=
self
.
dataValues
[
accessor
]
=
isEmpty
?
[]
:
include
.
daoFactory
.
bulkBuild
(
value
,
childOptions
)
self
.
dataValues
[
accessor
]
=
[]
self
[
accessor
]
=
self
.
dataValues
[
accessor
]
}
if
(
!
isEmpty
)
{
self
.
dataValues
[
accessor
].
push
(
daoInstance
)
}
}
}
}.
bind
(
this
))
};
};
// if an array with field names is passed to save()
// if an array with field names is passed to save()
...
...
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