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 c29500a3
authored
Nov 09, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use custom event emitter to drop the table during sync instead of extending mode…
…l factory with eventemitter
1 parent
f7cb6ef4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
lib/model-factory.js
lib/model-factory.js
View file @
c29500a
...
@@ -18,7 +18,6 @@ var ModelFactory = module.exports = function(name, attributes, options) {
...
@@ -18,7 +18,6 @@ var ModelFactory = module.exports = function(name, attributes, options) {
this
.
__addOptionalClassMethods
()
this
.
__addOptionalClassMethods
()
this
.
__findAutoIncrementField
()
this
.
__findAutoIncrementField
()
}
}
Utils
.
addEventEmitter
(
ModelFactory
)
ModelFactory
.
prototype
.
__defineGetter__
(
'QueryGenerator'
,
function
()
{
ModelFactory
.
prototype
.
__defineGetter__
(
'QueryGenerator'
,
function
()
{
return
this
.
modelManager
.
sequelize
.
connectorManager
.
getQueryGenerator
()
return
this
.
modelManager
.
sequelize
.
connectorManager
.
getQueryGenerator
()
...
@@ -28,21 +27,23 @@ ModelFactory.prototype.sync = function(options) {
...
@@ -28,21 +27,23 @@ ModelFactory.prototype.sync = function(options) {
options
=
Utils
.
merge
(
options
||
{},
this
.
options
)
options
=
Utils
.
merge
(
options
||
{},
this
.
options
)
var
self
=
this
var
self
=
this
var
eventEmitter
=
new
Utils
.
CustomEventEmitter
(
function
()
{
var
doQuery
=
function
()
{
var
doQuery
=
function
()
{
self
.
__query
(
self
.
QueryGenerator
.
createTableQuery
(
self
.
tableName
,
self
.
attributes
,
options
))
self
.
__query
(
self
.
QueryGenerator
.
createTableQuery
(
self
.
tableName
,
self
.
attributes
,
options
))
.
on
(
'success'
,
function
()
{
self
.
emit
(
'success'
,
self
)
})
.
on
(
'success'
,
function
()
{
eventEmitter
.
emit
(
'success'
,
self
)
})
.
on
(
'failure'
,
function
(
err
)
{
self
.
emit
(
'failure'
,
err
)
})
.
on
(
'failure'
,
function
(
err
)
{
eventEmitter
.
emit
(
'failure'
,
err
)
})
}
}
if
(
options
.
force
)
{
if
(
options
.
force
)
{
this
.
drop
()
self
.
drop
()
.
on
(
'success'
,
function
()
{
doQuery
()
})
.
on
(
'success'
,
function
()
{
doQuery
()
})
.
on
(
'failure'
,
function
(
err
)
{
self
.
emit
(
'failure'
,
err
)
})
.
on
(
'failure'
,
function
(
err
)
{
eventEmitter
.
emit
(
'failure'
,
err
)
})
}
else
{
}
else
{
doQuery
()
doQuery
()
}
}
})
return
this
return
eventEmitter
.
run
()
}
}
ModelFactory
.
prototype
.
drop
=
function
()
{
ModelFactory
.
prototype
.
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