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 cfc66e9e
authored
Apr 16, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Emit the sql event of the find method as well
1 parent
4ac8c613
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
25 deletions
lib/associations/has-one.js
lib/associations/has-one.js
View file @
cfc66e9
...
...
@@ -52,7 +52,7 @@ module.exports = (function() {
if
(
this
.
options
.
constraints
!==
false
)
{
this
.
options
.
onDelete
=
this
.
options
.
onDelete
||
'SET NULL'
this
.
options
.
onUpdate
=
this
.
options
.
onUpdate
||
'CASCADE'
}
}
Helpers
.
addForeignKeyConstraints
(
this
.
target
.
rawAttributes
[
this
.
identifier
],
this
.
source
,
this
.
target
,
this
.
options
)
// Sync attributes and setters/getters to DAO prototype
...
...
@@ -87,32 +87,34 @@ module.exports = (function() {
var
instance
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
instance
[
association
.
accessors
.
get
]().
success
(
function
(
oldInstance
)
{
if
(
oldInstance
)
{
oldInstance
[
association
.
identifier
]
=
null
oldInstance
.
save
(
Utils
.
_
.
extend
({},
options
,
{
fields
:
[
association
.
identifier
],
allowNull
:
[
association
.
identifier
],
association
:
true
}))
.
success
(
function
()
{
if
(
associatedInstance
)
{
associatedInstance
.
set
(
association
.
identifier
,
instance
.
get
(
association
.
sourceIdentifier
))
associatedInstance
.
save
(
options
).
proxy
(
emitter
)
}
else
{
emitter
.
emit
(
'success'
,
null
)
}
})
}
else
{
if
(
associatedInstance
)
{
associatedInstance
.
set
(
association
.
identifier
,
instance
.
get
(
association
.
sourceIdentifier
))
associatedInstance
.
save
(
options
).
proxy
(
emitter
)
instance
[
association
.
accessors
.
get
]()
.
success
(
function
(
oldInstance
)
{
if
(
oldInstance
)
{
oldInstance
[
association
.
identifier
]
=
null
oldInstance
.
save
(
Utils
.
_
.
extend
({},
options
,
{
fields
:
[
association
.
identifier
],
allowNull
:
[
association
.
identifier
],
association
:
true
}))
.
success
(
function
()
{
if
(
associatedInstance
)
{
associatedInstance
.
set
(
association
.
identifier
,
instance
.
get
(
association
.
sourceIdentifier
))
associatedInstance
.
save
(
options
).
proxy
(
emitter
)
}
else
{
emitter
.
emit
(
'success'
,
null
)
}
})
}
else
{
emitter
.
emit
(
'success'
,
null
)
if
(
associatedInstance
)
{
associatedInstance
.
set
(
association
.
identifier
,
instance
.
get
(
association
.
sourceIdentifier
))
associatedInstance
.
save
(
options
).
proxy
(
emitter
)
}
else
{
emitter
.
emit
(
'success'
,
null
)
}
}
}
})
}
)
.
proxy
(
emitter
,
{
events
:
[
'sql'
]
})
}).
run
()
}
...
...
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