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 8a262be3
authored
Jun 29, 2012
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaning up
1 parent
1bdf42dd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
lib/associations/has-one.js
lib/associations/has-one.js
View file @
8a262be
...
...
@@ -26,9 +26,7 @@ module.exports = (function() {
var
newAttributes
=
{}
this
.
identifier
=
this
.
options
.
foreignKey
||
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
source
.
tableName
)
+
"Id"
,
this
.
options
.
underscored
)
newAttributes
[
this
.
identifier
]
=
{
type
:
DataTypes
.
INTEGER
}
Utils
.
_
.
extend
(
this
.
target
.
rawAttributes
,
newAttributes
)
return
this
...
...
@@ -36,9 +34,14 @@ module.exports = (function() {
HasOne
.
prototype
.
injectGetter
=
function
(
obj
)
{
var
self
=
this
obj
[
this
.
accessors
.
get
]
=
function
()
{
var
id
=
obj
.
id
,
where
=
{}
where
[
self
.
identifier
]
=
id
return
self
.
target
.
find
({
where
:
where
})
}
return
this
}
...
...
@@ -50,11 +53,11 @@ module.exports = (function() {
var
customEventEmitter
=
new
Utils
.
CustomEventEmitter
(
function
()
{
obj
[
self
.
accessors
.
get
]().
success
(
function
(
oldObj
)
{
if
(
oldObj
)
{
oldObj
=
Utils
.
setAttributes
(
oldObj
,
self
.
identifier
,
self
.
options
.
omitNull
?
''
:
null
)
oldObj
[
self
.
identifier
]
=
self
.
options
.
omitNull
?
''
:
null
;
oldObj
.
save
()
}
associatedObject
=
Utils
.
setAttributes
(
associatedObject
,
self
.
identifier
,
obj
)
associatedObject
[
self
.
identifier
]
=
obj
.
id
associatedObject
.
save
()
.
success
(
function
()
{
customEventEmitter
.
emit
(
'success'
,
associatedObject
)
})
.
error
(
function
(
err
)
{
customEventEmitter
.
emit
(
'failure'
,
err
)
})
...
...
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