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 81a86579
authored
Oct 24, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added global drop method
1 parent
da0eb3e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
lib/sequelize/sequelize.js
lib/sequelize/sequelize.js
View file @
81a8657
...
...
@@ -17,7 +17,7 @@ var Sequelize = module.exports = function(database, username, password, options)
host
:
options
.
host
||
'localhost'
,
port
:
options
.
port
||
3306
}
this
.
modelManager
=
new
ModelManager
(
this
)
this
.
connectorManager
=
new
ConnectorManager
(
this
.
config
)
}
...
...
@@ -26,19 +26,19 @@ Sequelize.Utils = Utils
var
instanceMethods
=
{
define
:
function
(
modelName
,
attributes
,
options
)
{
options
=
options
||
{}
if
(
this
.
options
.
defineOptions
)
options
=
Sequelize
.
Utils
.
merge
(
options
,
this
.
options
.
defineOptions
)
var
model
=
this
.
modelManager
.
addModel
(
new
ModelDefinition
(
modelName
,
attributes
,
options
))
return
model
},
import
:
function
(
path
)
{
var
defineCall
=
require
(
path
)
return
defineCall
(
this
,
DataTypes
)
},
query
:
function
(
sql
,
callee
,
options
)
{
options
=
options
||
{}
...
...
@@ -48,27 +48,41 @@ var instanceMethods = {
return
this
.
connectorManager
.
query
(
sql
,
callee
,
options
)
},
sync
:
function
(
options
)
{
options
=
options
||
{}
if
(
this
.
options
.
syncOptions
)
options
=
Sequelize
.
Utils
.
merge
(
options
,
this
.
options
.
syncOptions
)
var
self
=
this
var
eventEmitter
=
new
Utils
.
CustomEventEmitter
(
function
()
{
var
chainer
=
new
Utils
.
QueryChainer
self
.
modelManager
.
models
.
forEach
(
function
(
model
)
{
chainer
.
add
(
model
.
sync
(
options
))
})
chainer
.
run
()
.
on
(
'success'
,
function
()
{
eventEmitter
.
emit
(
'success'
,
null
)
})
.
on
(
'failure'
,
function
(
err
)
{
eventEmitter
.
emit
(
'failure'
,
err
)
})
})
return
eventEmitter
.
run
()
},
drop
:
function
()
{
var
self
=
this
return
new
Utils
.
CustomEventEmitter
(
function
(
emitter
)
{
var
chainer
=
new
Utils
.
QueryChainer
self
.
modelManager
.
models
.
forEach
(
function
(
model
)
{
chainer
.
add
(
model
.
drop
())
})
chainer
.
run
()
.
on
(
'success'
,
function
()
{
emitter
.
emit
(
'success'
,
null
)
})
.
on
(
'failure'
,
function
(
err
)
{
emitter
.
emit
(
'failure'
,
err
)
})
}).
run
()
}
}
Sequelize
.
Utils
.
_
.
map
(
DataTypes
,
function
(
sql
,
accessor
)
{
Sequelize
[
accessor
]
=
sql
})
Sequelize
.
Utils
.
_
.
map
(
instanceMethods
,
function
(
fct
,
name
)
{
Sequelize
.
prototype
[
name
]
=
fct
})
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