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 910cd0c1
authored
Nov 16, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added success and failure jqXHR-like accessor
1 parent
d7ea69af
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
lib/emitters/custom-event-emitter.js
lib/model-factory.js
lib/query.js
lib/emitters/custom-event-emitter.js
View file @
910cd0c
...
@@ -18,5 +18,18 @@ module.exports = (function() {
...
@@ -18,5 +18,18 @@ module.exports = (function() {
return
this
return
this
}
}
CustomEventEmitter
.
prototype
.
success
=
CustomEventEmitter
.
prototype
.
ok
=
function
(
fct
)
{
this
.
success
(
fct
)
return
this
}
CustomEventEmitter
.
prototype
.
failure
=
CustomEventEmitter
.
prototype
.
fail
=
CustomEventEmitter
.
prototype
.
error
=
function
(
fct
)
{
this
.
on
(
'failure'
,
fct
)
return
this
}
return
CustomEventEmitter
return
CustomEventEmitter
})()
})()
lib/model-factory.js
View file @
910cd0c
...
@@ -34,14 +34,14 @@ module.exports = (function() {
...
@@ -34,14 +34,14 @@ module.exports = (function() {
var
eventEmitter
=
new
Utils
.
CustomEventEmitter
(
function
()
{
var
eventEmitter
=
new
Utils
.
CustomEventEmitter
(
function
()
{
var
doQuery
=
function
()
{
var
doQuery
=
function
()
{
query
.
call
(
self
,
self
.
QueryGenerator
.
createTableQuery
(
self
.
tableName
,
self
.
attributes
,
options
))
query
.
call
(
self
,
self
.
QueryGenerator
.
createTableQuery
(
self
.
tableName
,
self
.
attributes
,
options
))
.
on
(
'success'
,
function
()
{
eventEmitter
.
emit
(
'success'
,
self
)
})
.
success
(
function
()
{
eventEmitter
.
emit
(
'success'
,
self
)
})
.
on
(
'failure'
,
function
(
err
)
{
eventEmitter
.
emit
(
'failure'
,
err
)
})
.
error
(
function
(
err
)
{
eventEmitter
.
emit
(
'failure'
,
err
)
})
}
}
if
(
options
.
force
)
{
if
(
options
.
force
)
{
self
.
drop
()
self
.
drop
()
.
on
(
'success'
,
function
()
{
doQuery
()
})
.
success
(
function
()
{
doQuery
()
})
.
on
(
'failure'
,
function
(
err
)
{
eventEmitter
.
emit
(
'failure'
,
err
)
})
.
error
(
function
(
err
)
{
eventEmitter
.
emit
(
'failure'
,
err
)
})
}
else
{
}
else
{
doQuery
()
doQuery
()
}
}
...
...
lib/query.js
View file @
910cd0c
...
@@ -27,6 +27,16 @@ module.exports = (function() {
...
@@ -27,6 +27,16 @@ module.exports = (function() {
return
this
return
this
}
}
Query
.
prototype
.
success
=
Query
.
prototype
.
ok
=
function
(
fct
)
{
this
.
success
(
fct
)
return
this
}
Query
.
prototype
.
failure
=
Query
.
prototype
.
fail
=
Query
.
prototype
.
error
=
function
(
fct
)
{
this
.
on
(
'failure'
,
fct
)
return
this
}
//private
//private
var
bindClient
=
function
()
{
var
bindClient
=
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