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 091a4a24
authored
Dec 31, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added possibility to skip queries once a query failed
1 parent
5d6ec6ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
15 deletions
lib/query-chainer.js
lib/query-chainer.js
View file @
091a4a2
...
...
@@ -37,29 +37,44 @@ module.exports = (function() {
return
this
.
eventEmitter
.
run
()
}
QueryChainer
.
prototype
.
runSerial
=
function
()
{
var
self
=
this
QueryChainer
.
prototype
.
runSerial
=
function
(
options
)
{
var
self
=
this
options
=
Utils
.
_
.
extend
({
skipOnError
:
false
},
options
)
var
exec
=
function
()
{
var
serial
=
self
.
serials
.
pop
()
if
(
serial
)
{
var
emitter
=
serial
.
klass
[
serial
.
method
].
apply
(
serial
.
klass
,
serial
.
params
)
emitter
.
success
(
function
()
{
if
(
serial
.
options
&&
serial
.
options
.
success
)
{
serial
.
options
.
success
(
serial
.
klass
,
function
()
{
self
.
finishedEmits
++
exec
()
})
}
else
{
self
.
finishedEmits
++
exec
()
}
}).
error
(
function
(
err
)
{
serial
.
options
=
serial
.
options
||
{}
serial
.
options
.
before
&&
serial
.
options
.
before
(
serial
.
klass
)
var
onSuccess
=
function
()
{
serial
.
options
.
after
&&
serial
.
options
.
after
(
serial
.
klass
)
self
.
finishedEmits
++
exec
()
}
var
onError
=
function
(
err
)
{
serial
.
options
.
after
&&
serial
.
options
.
after
(
serial
.
klass
)
self
.
finishedEmits
++
self
.
fails
.
push
(
err
)
exec
()
})
}
if
(
options
.
skipOnError
&&
(
self
.
fails
.
length
>
0
))
{
onError
(
'Skipped due to earlier error!'
)
}
else
{
var
emitter
=
serial
.
klass
[
serial
.
method
].
apply
(
serial
.
klass
,
serial
.
params
)
emitter
.
success
(
function
()
{
if
(
serial
.
options
.
success
)
serial
.
options
.
success
(
serial
.
klass
,
onSuccess
)
else
onSuccess
()
}).
error
(
onError
)
}
}
else
{
self
.
wasRunning
=
true
finish
.
call
(
self
)
...
...
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