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 5b2bbf4f
authored
Jan 24, 2012
by
Meg Sharkey
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'sequelize/master'
2 parents
0ccbc17e
6d1bd3fc
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
10 deletions
bin/sequelize
lib/dialects/query.js
lib/dialects/sqlite/query.js
lib/emitters/custom-event-emitter.js
lib/query-chainer.js
lib/query-interface.js
spec/model-factory.spec.js
bin/sequelize
View file @
5b2bbf4
...
@@ -76,7 +76,7 @@ if(program.migrate) {
...
@@ -76,7 +76,7 @@ if(program.migrate) {
options
=
_
.
extend
(
options
,
{
logging
:
false
})
options
=
_
.
extend
(
options
,
{
logging
:
false
})
var
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
options
)
var
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
options
)
,
migratorOptions
=
{
path
:
__dirname
+
'/../migrations'
}
,
migratorOptions
=
{
path
:
migrationsPath
}
,
migrator
=
sequelize
.
getMigrator
(
migratorOptions
)
,
migrator
=
sequelize
.
getMigrator
(
migratorOptions
)
if
(
program
.
undo
)
{
if
(
program
.
undo
)
{
...
...
lib/dialects/query.js
View file @
5b2bbf4
...
@@ -4,7 +4,7 @@ module.exports = (function() {
...
@@ -4,7 +4,7 @@ module.exports = (function() {
var
Query
=
function
(
database
,
callee
,
options
)
{
var
Query
=
function
(
database
,
callee
,
options
)
{
throw
new
Error
(
'Constructor was not overwritten!'
)
throw
new
Error
(
'Constructor was not overwritten!'
)
}
}
Utils
.
addEventEmitter
(
Query
)
Utils
.
_
.
extend
(
Query
.
prototype
,
require
(
"../emitters/custom-event-emitter"
).
prototype
)
Query
.
prototype
.
run
=
function
(
sql
)
{
Query
.
prototype
.
run
=
function
(
sql
)
{
throw
new
Error
(
"The run method wasn't overwritten!"
)
throw
new
Error
(
"The run method wasn't overwritten!"
)
...
...
lib/dialects/sqlite/query.js
View file @
5b2bbf4
...
@@ -2,8 +2,6 @@ var Utils = require("../../utils")
...
@@ -2,8 +2,6 @@ var Utils = require("../../utils")
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
Query
=
function
(
database
,
callee
,
options
)
{
var
Query
=
function
(
database
,
callee
,
options
)
{
var
self
=
this
this
.
database
=
database
this
.
database
=
database
this
.
callee
=
callee
this
.
callee
=
callee
this
.
options
=
Utils
.
_
.
extend
({
this
.
options
=
Utils
.
_
.
extend
({
...
...
lib/emitters/custom-event-emitter.js
View file @
5b2bbf4
...
@@ -13,12 +13,14 @@ module.exports = (function() {
...
@@ -13,12 +13,14 @@ module.exports = (function() {
// delay the function call and return the emitter
// delay the function call and return the emitter
setTimeout
(
function
(){
setTimeout
(
function
(){
self
.
fct
.
call
(
self
,
self
)
self
.
fct
.
call
(
self
,
self
)
},
5
)
},
1
)
return
this
return
this
}
}
CustomEventEmitter
.
prototype
.
success
=
CustomEventEmitter
.
prototype
.
ok
=
function
(
fct
)
{
CustomEventEmitter
.
prototype
.
success
=
CustomEventEmitter
.
prototype
.
ok
=
function
(
fct
)
{
this
.
on
(
'success'
,
fct
)
this
.
on
(
'success'
,
fct
)
return
this
return
this
}
}
...
...
lib/query-chainer.js
View file @
5b2bbf4
...
@@ -15,7 +15,6 @@ module.exports = (function() {
...
@@ -15,7 +15,6 @@ module.exports = (function() {
emitters
=
emitters
||
[]
emitters
=
emitters
||
[]
emitters
.
forEach
(
function
(
emitter
)
{
self
.
add
(
emitter
)
})
emitters
.
forEach
(
function
(
emitter
)
{
self
.
add
(
emitter
)
})
}
}
Utils
.
addEventEmitter
(
QueryChainer
)
QueryChainer
.
prototype
.
add
=
function
(
emitterOrKlass
,
method
,
params
,
options
)
{
QueryChainer
.
prototype
.
add
=
function
(
emitterOrKlass
,
method
,
params
,
options
)
{
if
(
!!
method
)
{
if
(
!!
method
)
{
...
...
lib/query-interface.js
View file @
5b2bbf4
...
@@ -37,7 +37,7 @@ module.exports = (function() {
...
@@ -37,7 +37,7 @@ module.exports = (function() {
self
.
showAllTables
().
success
(
function
(
tableNames
)
{
self
.
showAllTables
().
success
(
function
(
tableNames
)
{
tableNames
.
forEach
(
function
(
tableName
)
{
tableNames
.
forEach
(
function
(
tableName
)
{
chainer
.
add
(
self
.
sequelize
.
getQueryInterface
().
dropTable
(
tableName
))
chainer
.
add
(
self
.
dropTable
(
tableName
))
})
})
chainer
chainer
.
run
()
.
run
()
...
...
spec/model-factory.spec.js
View file @
5b2bbf4
...
@@ -343,10 +343,45 @@ describe('ModelFactory', function() {
...
@@ -343,10 +343,45 @@ describe('ModelFactory', function() {
})
})
})
})
it
(
"sorts the results"
,
function
()
{
it
(
"sorts the results via id"
,
function
()
{
Helpers
.
Factories
.
User
({
name
:
'user'
,
bio
:
'foobar'
},
function
(
_users
)
{
users
=
_users
},
2
)
Helpers
.
async
(
function
(
done
)
{
setTimeout
(
function
()
{
User
.
create
({
name
:
'user'
,
bio
:
'foobar'
}).
success
(
function
(
user
)
{
users
.
push
(
user
)
done
()
})
},
2000
)
})
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
User
.
findAll
({
order
:
"id DESC"
}).
success
(
function
(
users
)
{
User
.
findAll
({
order
:
"id DESC"
}).
success
(
function
(
users
)
{
expect
(
users
[
0
].
id
).
toBeGreaterThan
(
users
[
1
].
id
)
expect
(
users
[
0
].
id
).
toBeGreaterThan
(
users
[
2
].
id
)
done
()
})
})
})
it
(
"sorts the results via createdAt"
,
function
()
{
Helpers
.
Factories
.
User
({
name
:
'user'
,
bio
:
'foobar'
},
function
(
_users
)
{
users
=
_users
},
2
)
Helpers
.
async
(
function
(
done
)
{
setTimeout
(
function
()
{
User
.
create
({
name
:
'user'
,
bio
:
'foobar'
}).
success
(
function
(
user
)
{
users
.
push
(
user
)
done
()
})
},
2000
)
})
Helpers
.
async
(
function
(
done
)
{
User
.
findAll
({
order
:
'createdAt DESC'
}).
success
(
function
(
users
)
{
expect
(
users
[
0
].
id
).
toBeGreaterThan
(
users
[
2
].
id
)
done
()
done
()
})
})
})
})
...
...
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