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 10ec7ff6
authored
May 04, 2013
by
Martin Aspeli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tidy up setting of new attributes
1 parent
559e1cef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
lib/associations/belongs-to.js
lib/associations/has-many.js
lib/associations/has-one.js
lib/associations/belongs-to.js
View file @
10ec7ff
...
@@ -24,12 +24,14 @@ module.exports = (function() {
...
@@ -24,12 +24,14 @@ module.exports = (function() {
this
.
identifier
=
this
.
options
.
foreignKey
||
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
target
.
tableName
)
+
"Id"
,
this
.
source
.
options
.
underscored
)
this
.
identifier
=
this
.
options
.
foreignKey
||
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
target
.
tableName
)
+
"Id"
,
this
.
source
.
options
.
underscored
)
newAttributes
[
this
.
identifier
]
=
{
type
:
DataTypes
.
INTEGER
}
newAttributes
[
this
.
identifier
]
=
{
type
:
DataTypes
.
INTEGER
}
if
(
typeof
this
.
options
.
foreignKey
===
"undefined"
||
this
.
options
.
foreignKey
===
true
)
{
if
(
this
.
options
.
foreignKeyConstraint
||
this
.
options
.
onDelete
||
this
.
options
.
onUpdate
)
{
newAttributes
[
this
.
identifier
].
references
=
this
.
target
.
tableName
,
newAttributes
[
this
.
identifier
].
references
=
this
.
target
.
tableName
,
newAttributes
[
this
.
identifier
].
referencesKeys
=
Utils
.
_
.
reduce
(
this
.
source
.
rawAttributes
,
function
(
memo
,
value
,
key
)
{
if
(
value
.
primaryKey
)
{
memo
.
push
(
key
)
}
return
memo
},
[]
)
newAttributes
[
this
.
identifier
].
referencesKeys
=
Utils
.
_
.
filter
(
Utils
.
_
.
keys
(
this
.
target
.
rawAttributes
),
function
(
key
)
{
return
this
.
target
.
rawAttributes
[
key
].
primaryKey
},
this
)
newAttributes
[
this
.
identifier
].
onDelete
=
this
.
options
.
onDelete
,
newAttributes
[
this
.
identifier
].
onDelete
=
this
.
options
.
onDelete
,
newAttributes
[
this
.
identifier
].
onUpdate
=
this
.
options
.
onUpdate
newAttributes
[
this
.
identifier
].
onUpdate
=
this
.
options
.
onUpdate
}
}
Utils
.
_
.
defaults
(
this
.
source
.
rawAttributes
,
newAttributes
)
Utils
.
_
.
defaults
(
this
.
source
.
rawAttributes
,
newAttributes
)
// Sync attributes to DAO proto each time a new assoc is added
// Sync attributes to DAO proto each time a new assoc is added
...
...
lib/associations/has-many.js
View file @
10ec7ff
...
@@ -65,12 +65,14 @@ module.exports = (function() {
...
@@ -65,12 +65,14 @@ module.exports = (function() {
}
else
{
}
else
{
var
newAttributes
=
{}
var
newAttributes
=
{}
newAttributes
[
this
.
identifier
]
=
{
type
:
DataTypes
.
INTEGER
}
newAttributes
[
this
.
identifier
]
=
{
type
:
DataTypes
.
INTEGER
}
if
(
typeof
this
.
options
.
foreignKey
===
"undefined"
||
this
.
options
.
foreignKey
===
true
)
{
if
(
this
.
options
.
foreignKeyConstraint
||
this
.
options
.
onDelete
||
this
.
options
.
onUpdate
)
{
newAttributes
[
this
.
identifier
].
references
=
this
.
source
.
tableName
newAttributes
[
this
.
identifier
].
references
=
this
.
source
.
tableName
newAttributes
[
this
.
identifier
].
referencesKeys
=
Utils
.
_
.
reduce
(
this
.
source
.
rawAttributes
,
function
(
memo
,
value
,
key
)
{
if
(
value
.
primaryKey
)
{
memo
.
push
(
key
)
}
return
memo
},
[]
)
newAttributes
[
this
.
identifier
].
referencesKeys
=
Utils
.
_
.
filter
(
Utils
.
_
.
keys
(
this
.
source
.
rawAttributes
),
function
(
key
)
{
return
this
.
source
.
rawAttributes
[
key
].
primaryKey
},
this
)
newAttributes
[
this
.
identifier
].
onDelete
=
this
.
options
.
onDelete
newAttributes
[
this
.
identifier
].
onDelete
=
this
.
options
.
onDelete
newAttributes
[
this
.
identifier
].
onUpdate
=
this
.
options
.
onUpdate
newAttributes
[
this
.
identifier
].
onUpdate
=
this
.
options
.
onUpdate
}
}
Utils
.
_
.
defaults
(
this
.
target
.
rawAttributes
,
newAttributes
)
Utils
.
_
.
defaults
(
this
.
target
.
rawAttributes
,
newAttributes
)
}
}
...
...
lib/associations/has-one.js
View file @
10ec7ff
...
@@ -29,12 +29,14 @@ module.exports = (function() {
...
@@ -29,12 +29,14 @@ module.exports = (function() {
this
.
identifier
=
this
.
options
.
foreignKey
||
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
source
.
tableName
)
+
"Id"
,
this
.
options
.
underscored
)
this
.
identifier
=
this
.
options
.
foreignKey
||
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
source
.
tableName
)
+
"Id"
,
this
.
options
.
underscored
)
newAttributes
[
this
.
identifier
]
=
{
type
:
DataTypes
.
INTEGER
}
newAttributes
[
this
.
identifier
]
=
{
type
:
DataTypes
.
INTEGER
}
if
(
typeof
this
.
options
.
foreignKey
===
"undefined"
||
this
.
options
.
foreignKey
===
true
)
{
if
(
this
.
options
.
foreignKeyConstraint
||
this
.
options
.
onDelete
||
this
.
options
.
onUpdate
)
{
newAttributes
[
this
.
identifier
].
references
=
this
.
source
.
tableName
,
newAttributes
[
this
.
identifier
].
references
=
this
.
source
.
tableName
,
newAttributes
[
this
.
identifier
].
referencesKeys
=
Utils
.
_
.
reduce
(
this
.
source
.
rawAttributes
,
function
(
memo
,
value
,
key
)
{
if
(
value
.
primaryKey
)
{
memo
.
push
(
key
)
}
return
memo
},
[]
)
newAttributes
[
this
.
identifier
].
referencesKeys
=
Utils
.
_
.
filter
(
Utils
.
_
.
keys
(
this
.
source
.
rawAttributes
),
function
(
key
)
{
return
this
.
source
.
rawAttributes
[
key
].
primaryKey
},
this
)
newAttributes
[
this
.
identifier
].
onDelete
=
this
.
options
.
onDelete
,
newAttributes
[
this
.
identifier
].
onDelete
=
this
.
options
.
onDelete
,
newAttributes
[
this
.
identifier
].
onUpdate
=
this
.
options
.
onUpdate
newAttributes
[
this
.
identifier
].
onUpdate
=
this
.
options
.
onUpdate
}
}
Utils
.
_
.
defaults
(
this
.
target
.
rawAttributes
,
newAttributes
)
Utils
.
_
.
defaults
(
this
.
target
.
rawAttributes
,
newAttributes
)
// Sync attributes to DAO proto each time a new assoc is added
// Sync attributes to DAO proto each time a new assoc is added
...
...
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