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 f99845b6
authored
Feb 07, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor
1 parent
78bb1a2a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
lib/dao-factory.js
lib/dao.js
lib/dao-factory.js
View file @
f99845b
...
@@ -203,17 +203,19 @@ module.exports = (function() {
...
@@ -203,17 +203,19 @@ module.exports = (function() {
this
.
refreshAttributes
();
this
.
refreshAttributes
();
this
.
DAO
.
prototype
.
booleanValues
=
[]
this
.
_booleanAttributes
=
[]
this
.
DAO
.
prototype
.
dateAttributes
=
[]
this
.
_dateAttributes
=
[]
this
.
DAO
.
prototype
.
booleanValues
=
this
.
_booleanAttributes
this
.
DAO
.
prototype
.
dateAttributes
=
this
.
_dateAttributes
this
.
DAO
.
prototype
.
defaultValues
=
{}
this
.
DAO
.
prototype
.
defaultValues
=
{}
this
.
DAO
.
prototype
.
validators
=
{}
this
.
DAO
.
prototype
.
validators
=
{}
Utils
.
_
.
each
(
this
.
rawAttributes
,
function
(
definition
,
name
)
{
Utils
.
_
.
each
(
this
.
rawAttributes
,
function
(
definition
,
name
)
{
if
(((
definition
===
DataTypes
.
BOOLEAN
)
||
(
definition
.
type
===
DataTypes
.
BOOLEAN
)))
{
if
(((
definition
===
DataTypes
.
BOOLEAN
)
||
(
definition
.
type
===
DataTypes
.
BOOLEAN
)))
{
self
.
DAO
.
prototype
.
booleanValu
es
.
push
(
name
);
self
.
_booleanAttribut
es
.
push
(
name
);
}
}
if
(((
definition
===
DataTypes
.
DATE
)
||
(
definition
.
type
===
DataTypes
.
DATE
)
||
(
definition
.
originalType
===
DataTypes
.
DATE
)))
{
if
(((
definition
===
DataTypes
.
DATE
)
||
(
definition
.
type
===
DataTypes
.
DATE
)
||
(
definition
.
originalType
===
DataTypes
.
DATE
)))
{
self
.
DAO
.
prototype
.
dateAttributes
.
push
(
name
);
self
.
_
dateAttributes
.
push
(
name
);
}
}
if
(
definition
.
hasOwnProperty
(
'defaultValue'
))
{
if
(
definition
.
hasOwnProperty
(
'defaultValue'
))
{
self
.
DAO
.
prototype
.
defaultValues
[
name
]
=
Utils
.
_
.
partial
(
self
.
DAO
.
prototype
.
defaultValues
[
name
]
=
Utils
.
_
.
partial
(
...
@@ -225,15 +227,19 @@ module.exports = (function() {
...
@@ -225,15 +227,19 @@ module.exports = (function() {
}
}
})
})
this
.
DAO
.
prototype
.
_hasBooleanAttributes
=
!!
this
.
DAO
.
prototype
.
booleanValu
es
.
length
this
.
_hasBooleanAttributes
=
!!
this
.
_booleanAttribut
es
.
length
this
.
DAO
.
prototype
.
_isBooleanAttribute
=
Utils
.
_
.
memoize
(
function
(
key
)
{
this
.
_isBooleanAttribute
=
Utils
.
_
.
memoize
(
function
(
key
)
{
return
self
.
DAO
.
prototype
.
booleanValu
es
.
indexOf
(
key
)
!==
-
1
return
self
.
_booleanAttribut
es
.
indexOf
(
key
)
!==
-
1
})
})
this
.
DAO
.
prototype
.
_hasBooleanAttributes
=
this
.
_hasBooleanAttributes
this
.
DAO
.
prototype
.
_isBooleanAttribute
=
this
.
_isBooleanAttribute
this
.
DAO
.
prototype
.
_hasDateAttributes
=
!!
this
.
DAO
.
prototype
.
dateAttributes
.
length
this
.
_hasDateAttributes
=
!!
this
.
_
dateAttributes
.
length
this
.
DAO
.
prototype
.
_isDateAttribute
=
Utils
.
_
.
memoize
(
function
(
key
)
{
this
.
_isDateAttribute
=
Utils
.
_
.
memoize
(
function
(
key
)
{
return
self
.
DAO
.
prototype
.
dateAttributes
.
indexOf
(
key
)
!==
-
1
return
self
.
_
dateAttributes
.
indexOf
(
key
)
!==
-
1
})
})
this
.
DAO
.
prototype
.
_hasDateAttributes
=
this
.
_hasDateAttributes
this
.
DAO
.
prototype
.
_isDateAttribute
=
this
.
_isDateAttribute
this
.
DAO
.
prototype
.
__factory
=
this
this
.
DAO
.
prototype
.
__factory
=
this
this
.
DAO
.
prototype
.
daoFactory
=
this
this
.
DAO
.
prototype
.
daoFactory
=
this
...
...
lib/dao.js
View file @
f99845b
...
@@ -123,7 +123,7 @@ module.exports = (function() {
...
@@ -123,7 +123,7 @@ module.exports = (function() {
}
}
// If raw, and we're not dealing with includes, just set it straight on the dataValues object
// If raw, and we're not dealing with includes, just set it straight on the dataValues object
if
(
options
.
raw
&&
!
(
this
.
options
&&
this
.
options
.
include
)
&&
!
this
.
_hasBooleanAttributes
)
{
if
(
options
.
raw
&&
!
(
this
.
options
&&
this
.
options
.
include
)
&&
!
this
.
Model
.
_hasBooleanAttributes
)
{
if
(
Object
.
keys
(
this
.
dataValues
).
length
)
{
if
(
Object
.
keys
(
this
.
dataValues
).
length
)
{
this
.
dataValues
=
_
.
extend
(
this
.
dataValues
,
values
)
this
.
dataValues
=
_
.
extend
(
this
.
dataValues
,
values
)
}
else
{
}
else
{
...
@@ -188,7 +188,7 @@ module.exports = (function() {
...
@@ -188,7 +188,7 @@ module.exports = (function() {
DAO
.
prototype
.
changed
=
function
(
key
)
{
DAO
.
prototype
.
changed
=
function
(
key
)
{
if
(
key
)
{
if
(
key
)
{
if
(
this
.
_isDateAttribute
(
key
)
&&
this
.
_previousDataValues
[
key
]
&&
this
.
dataValues
[
key
])
{
if
(
this
.
Model
.
_isDateAttribute
(
key
)
&&
this
.
_previousDataValues
[
key
]
&&
this
.
dataValues
[
key
])
{
return
this
.
_previousDataValues
[
key
].
valueOf
()
!==
this
.
dataValues
[
key
].
valueOf
()
return
this
.
_previousDataValues
[
key
].
valueOf
()
!==
this
.
dataValues
[
key
].
valueOf
()
}
}
return
this
.
_previousDataValues
[
key
]
!==
this
.
dataValues
[
key
]
return
this
.
_previousDataValues
[
key
]
!==
this
.
dataValues
[
key
]
...
@@ -356,7 +356,7 @@ module.exports = (function() {
...
@@ -356,7 +356,7 @@ module.exports = (function() {
args
=
[
self
,
self
.
QueryInterface
.
QueryGenerator
.
addSchema
(
self
.
Model
),
values
,
options
]
args
=
[
self
,
self
.
QueryInterface
.
QueryGenerator
.
addSchema
(
self
.
Model
),
values
,
options
]
hook
=
'Create'
hook
=
'Create'
}
else
{
}
else
{
var
identifier
=
self
.
__options
.
hasPrimaryKeys
?
self
.
primaryKeyValues
:
{
id
:
self
.
id
}
var
identifier
=
self
.
primaryKeyValues
if
(
identifier
===
null
&&
self
.
__options
.
whereCollection
!==
null
)
{
if
(
identifier
===
null
&&
self
.
__options
.
whereCollection
!==
null
)
{
identifier
=
self
.
__options
.
whereCollection
;
identifier
=
self
.
__options
.
whereCollection
;
...
...
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