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 e60f8233
authored
Aug 04, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed chainQuery method + allowing deletion if passing limit:null
1 parent
5dce3a5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
src/Sequelize.js
src/Sequelize.js
View file @
e60f823
...
...
@@ -44,22 +44,32 @@ var classMethods = {
query
=
"UPDATE %{table} SET %{values} WHERE id = %{id}"
break
case
'delete'
:
query
=
"DELETE FROM %{table} WHERE %{where} LIMIT 1"
query
=
"DELETE FROM %{table} WHERE %{where}"
if
(
values
.
limit
!=
null
)
query
+=
" LIMIT 1"
break
}
return
SequelizeHelper
.
evaluateTemplate
(
query
,
values
)
},
chainQueries
:
function
(
queries
,
callback
)
{
// queries = [{method: object}, {method: object}, {method: object}]
var
executeQuery
=
function
(
index
)
{
queries
[
index
](
function
()
{
var
queryHash
=
queries
[
index
]
var
method
=
SequelizeHelper
.
Hash
.
keys
(
queryHash
)
var
object
=
queryHash
[
method
]
object
[
method
](
function
()
{
if
(
queries
.
length
>
(
index
+
1
))
executeQuery
(
index
+
1
)
else
if
(
callback
)
callback
()
})
}
executeQuery
(
0
)
if
(
queries
.
length
>
0
)
executeQuery
(
0
)
else
if
(
callback
)
callback
()
}
}
...
...
@@ -80,7 +90,7 @@ Sequelize.prototype = {
table
.
klass
.
prepareAssociations
()
})
if
(
SequelizeHelper
.
Hash
.
keys
(
tables
).
length
==
0
)
if
(
SequelizeHelper
.
Hash
.
keys
(
t
his
.
t
ables
).
length
==
0
)
callback
()
else
SequelizeHelper
.
Hash
.
forEach
(
tables
,
function
(
table
)
{
...
...
@@ -103,7 +113,7 @@ Sequelize.prototype = {
table
.
klass
.
drop
(
function
()
{
finished
.
push
(
true
)
if
(
finished
.
length
==
SequelizeHelper
.
Hash
.
keys
(
tables
).
length
)
callback
()
if
(
callback
)
callback
()
})
})
},
...
...
@@ -114,7 +124,6 @@ Sequelize.prototype = {
var
table
=
new
SequelizeTable
(
this
,
SequelizeHelper
.
SQL
.
asTableName
(
name
),
attributes
)
table
.
attributes
=
attributes
this
.
tables
[
name
]
=
{
klass
:
table
,
attributes
:
attributes
}
table
.
sequelize
=
this
...
...
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