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 b4d0b9bd
authored
Aug 04, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added possibility to pass params to chainQueries method
1 parent
43f3efa9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
14 deletions
src/Sequelize.js
src/Sequelize.js
View file @
b4d0b9b
...
@@ -53,23 +53,20 @@ var classMethods = {
...
@@ -53,23 +53,20 @@ var classMethods = {
return
SequelizeHelper
.
evaluateTemplate
(
query
,
values
)
return
SequelizeHelper
.
evaluateTemplate
(
query
,
values
)
},
},
chainQueries
:
function
(
queries
,
callback
)
{
chainQueries
:
function
(
queries
,
callback
)
{
// queries = [{method: object}, {method: object}, {method: object}]
// queries = [{method: object}, {method: object
, params: [1,2,3]
}, {method: object}]
var
executeQuery
=
function
(
index
)
{
var
executeQuery
=
function
(
index
)
{
var
queryHash
=
queries
[
index
]
var
queryHash
=
queries
[
index
]
var
method
=
SequelizeHelper
.
Hash
.
keys
(
queryHash
)
var
method
=
SequelizeHelper
.
Array
.
without
(
SequelizeHelper
.
Hash
.
keys
(
queryHash
),
"params"
)[
0
]
var
object
=
queryHash
[
method
]
var
object
=
queryHash
[
method
]
var
iterator
=
function
()
{
if
(
queries
.
length
>
(
index
+
1
))
executeQuery
(
index
+
1
)
else
if
(
callback
)
callback
()
}
object
[
method
](
function
()
{
object
[
method
].
apply
(
object
,
SequelizeHelper
.
Array
.
join
(
queryHash
.
params
||
[],
[
iterator
]))
if
(
queries
.
length
>
(
index
+
1
))
executeQuery
(
index
+
1
)
else
if
(
callback
)
callback
()
})
}
}
if
(
queries
.
length
>
0
)
if
(
queries
.
length
>
0
)
executeQuery
(
0
)
executeQuery
(
0
)
else
if
(
callback
)
callback
()
else
if
(
callback
)
callback
()
}
}
}
}
...
@@ -106,8 +103,7 @@ Sequelize.prototype = {
...
@@ -106,8 +103,7 @@ Sequelize.prototype = {
var
finished
=
[]
var
finished
=
[]
var
tables
=
this
.
tables
var
tables
=
this
.
tables
if
(
SequelizeHelper
.
Hash
.
keys
(
tables
).
length
==
0
)
if
((
SequelizeHelper
.
Hash
.
keys
(
tables
).
length
==
0
)
&&
callback
)
callback
()
callback
()
else
else
SequelizeHelper
.
Hash
.
forEach
(
tables
,
function
(
table
,
tableName
)
{
SequelizeHelper
.
Hash
.
forEach
(
tables
,
function
(
table
,
tableName
)
{
table
.
klass
.
drop
(
function
()
{
table
.
klass
.
drop
(
function
()
{
...
...
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