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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
src/Sequelize.js
src/Sequelize.js
View file @
e60f823
...
@@ -44,22 +44,32 @@ var classMethods = {
...
@@ -44,22 +44,32 @@ var classMethods = {
query
=
"UPDATE %{table} SET %{values} WHERE id = %{id}"
query
=
"UPDATE %{table} SET %{values} WHERE id = %{id}"
break
break
case
'delete'
:
case
'delete'
:
query
=
"DELETE FROM %{table} WHERE %{where} LIMIT 1"
query
=
"DELETE FROM %{table} WHERE %{where}"
if
(
values
.
limit
!=
null
)
query
+=
" LIMIT 1"
break
break
}
}
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}]
var
executeQuery
=
function
(
index
)
{
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
))
if
(
queries
.
length
>
(
index
+
1
))
executeQuery
(
index
+
1
)
executeQuery
(
index
+
1
)
else
else
if
(
callback
)
callback
()
if
(
callback
)
callback
()
})
})
}
}
if
(
queries
.
length
>
0
)
executeQuery
(
0
)
executeQuery
(
0
)
else
if
(
callback
)
callback
()
}
}
}
}
...
@@ -80,7 +90,7 @@ Sequelize.prototype = {
...
@@ -80,7 +90,7 @@ Sequelize.prototype = {
table
.
klass
.
prepareAssociations
()
table
.
klass
.
prepareAssociations
()
})
})
if
(
SequelizeHelper
.
Hash
.
keys
(
tables
).
length
==
0
)
if
(
SequelizeHelper
.
Hash
.
keys
(
t
his
.
t
ables
).
length
==
0
)
callback
()
callback
()
else
else
SequelizeHelper
.
Hash
.
forEach
(
tables
,
function
(
table
)
{
SequelizeHelper
.
Hash
.
forEach
(
tables
,
function
(
table
)
{
...
@@ -103,7 +113,7 @@ Sequelize.prototype = {
...
@@ -103,7 +113,7 @@ Sequelize.prototype = {
table
.
klass
.
drop
(
function
()
{
table
.
klass
.
drop
(
function
()
{
finished
.
push
(
true
)
finished
.
push
(
true
)
if
(
finished
.
length
==
SequelizeHelper
.
Hash
.
keys
(
tables
).
length
)
if
(
finished
.
length
==
SequelizeHelper
.
Hash
.
keys
(
tables
).
length
)
callback
()
if
(
callback
)
callback
()
})
})
})
})
},
},
...
@@ -114,7 +124,6 @@ Sequelize.prototype = {
...
@@ -114,7 +124,6 @@ Sequelize.prototype = {
var
table
=
new
SequelizeTable
(
this
,
SequelizeHelper
.
SQL
.
asTableName
(
name
),
attributes
)
var
table
=
new
SequelizeTable
(
this
,
SequelizeHelper
.
SQL
.
asTableName
(
name
),
attributes
)
table
.
attributes
=
attributes
table
.
attributes
=
attributes
this
.
tables
[
name
]
=
{
klass
:
table
,
attributes
:
attributes
}
this
.
tables
[
name
]
=
{
klass
:
table
,
attributes
:
attributes
}
table
.
sequelize
=
this
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