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 3ee9e121
authored
Apr 27, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sequelize#sync
1 parent
bf37e532
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
lib/sequelize/sequelize.js
test/Sequelize/sync.js
lib/sequelize/sequelize.js
View file @
3ee9e12
...
@@ -40,6 +40,21 @@ var instanceMethods = {
...
@@ -40,6 +40,21 @@ var instanceMethods = {
options
=
options
||
{}
options
=
options
||
{}
options
.
logging
=
this
.
options
.
hasOwnProperty
(
'logging'
)
?
this
.
options
.
logging
:
true
options
.
logging
=
this
.
options
.
hasOwnProperty
(
'logging'
)
?
this
.
options
.
logging
:
true
return
new
Query
(
this
.
config
,
callee
,
options
).
run
(
sql
)
return
new
Query
(
this
.
config
,
callee
,
options
).
run
(
sql
)
},
sync
:
function
(
options
)
{
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
()
{
eventEmitter
.
emit
(
'failure'
,
null
)
})
})
return
eventEmitter
.
run
()
}
}
}
}
...
...
test/Sequelize/sync.js
0 → 100644
View file @
3ee9e12
var
assert
=
require
(
"assert"
)
,
config
=
require
(
"./../config"
)
,
Sequelize
=
require
(
"./../../index"
)
,
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
{
logging
:
false
})
module
.
exports
=
{
'it should sync all models - so instances can be created and saved to the database without failures'
:
function
(
exit
)
{
var
Project
=
sequelize
.
define
(
'project'
+
parseInt
(
Math
.
random
()
*
9999999999999999999
),
{
title
:
Sequelize
.
STRING
})
var
Task
=
sequelize
.
define
(
'task'
+
parseInt
(
Math
.
random
()
*
99999999999999999
),
{
title
:
Sequelize
.
STRING
})
sequelize
.
sync
().
on
(
'success'
,
function
()
{
Project
.
create
({
title
:
'bla'
}).
on
(
'success'
,
function
()
{
Task
.
create
({
title
:
'bla'
}).
on
(
'success'
,
function
()
{
exit
(
function
(){})
})
})
})
}
}
\ No newline at end of file
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