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 f878edbc
authored
Nov 09, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Model#all is now a function
1 parent
d1456c7d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
11 additions
and
11 deletions
spec/model-definition.spec.js
test/Model/add-remove-association.js
test/Model/build.js
test/Model/destroy.js
test/Model/find-findAll-all.js
test/Model/save.js
test/Sequelize/define.js
spec/model-definition.spec.js
View file @
f878edb
...
@@ -18,7 +18,7 @@ describe('ModelDefinition', function() {
...
@@ -18,7 +18,7 @@ describe('ModelDefinition', function() {
it
(
"should return all users"
,
function
()
{
it
(
"should return all users"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
done
()
done
()
expect
(
users
.
length
).
toEqual
(
2
)
expect
(
users
.
length
).
toEqual
(
2
)
}).
on
(
'failure'
,
function
(
err
)
{
console
.
log
(
err
)
})
}).
on
(
'failure'
,
function
(
err
)
{
console
.
log
(
err
)
})
...
...
test/Model/add-remove-association.js
View file @
f878edb
...
@@ -33,8 +33,8 @@ var initialize = function(options, callback) {
...
@@ -33,8 +33,8 @@ var initialize = function(options, callback) {
module
.
exports
=
{
module
.
exports
=
{
'it should correctly add an association to the model'
:
function
(
exit
)
{
'it should correctly add an association to the model'
:
function
(
exit
)
{
initialize
({
taskCount
:
5
,
userCount
:
2
},
function
(
Task
,
User
)
{
initialize
({
taskCount
:
5
,
userCount
:
2
},
function
(
Task
,
User
)
{
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
Task
.
all
.
on
(
'success'
,
function
(
tasks
)
{
Task
.
all
()
.
on
(
'success'
,
function
(
tasks
)
{
var
user
=
users
[
0
]
var
user
=
users
[
0
]
user
.
getTasks
().
on
(
'success'
,
function
(
_tasks
)
{
user
.
getTasks
().
on
(
'success'
,
function
(
_tasks
)
{
...
@@ -53,8 +53,8 @@ module.exports = {
...
@@ -53,8 +53,8 @@ module.exports = {
},
},
'it should correctly remove associated objects'
:
function
(
exit
)
{
'it should correctly remove associated objects'
:
function
(
exit
)
{
initialize
({
taskCount
:
5
,
userCount
:
2
},
function
(
Task
,
User
)
{
initialize
({
taskCount
:
5
,
userCount
:
2
},
function
(
Task
,
User
)
{
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
Task
.
all
.
on
(
'success'
,
function
(
tasks
)
{
Task
.
all
()
.
on
(
'success'
,
function
(
tasks
)
{
var
user
=
users
[
0
]
var
user
=
users
[
0
]
user
.
getTasks
().
on
(
'success'
,
function
(
_tasks
)
{
user
.
getTasks
().
on
(
'success'
,
function
(
_tasks
)
{
...
...
test/Model/build.js
View file @
f878edb
...
@@ -17,7 +17,7 @@ module.exports = {
...
@@ -17,7 +17,7 @@ module.exports = {
'build should not create database entries'
:
function
(
exit
)
{
'build should not create database entries'
:
function
(
exit
)
{
initUsers
(
10
,
function
(
users
,
User
)
{
initUsers
(
10
,
function
(
users
,
User
)
{
assert
.
eql
(
users
.
length
,
10
)
assert
.
eql
(
users
.
length
,
10
)
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
assert
.
eql
(
users
.
length
,
0
)
assert
.
eql
(
users
.
length
,
0
)
exit
(
function
(){})
exit
(
function
(){})
})
})
...
...
test/Model/destroy.js
View file @
f878edb
...
@@ -8,10 +8,10 @@ module.exports = {
...
@@ -8,10 +8,10 @@ module.exports = {
var
User
=
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
var
User
=
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
})
User
.
sync
({
force
:
true
}).
on
(
'success'
,
function
()
{
User
.
sync
({
force
:
true
}).
on
(
'success'
,
function
()
{
User
.
create
({
name
:
'hallo'
,
bio
:
'welt'
}).
on
(
'success'
,
function
(
u
)
{
User
.
create
({
name
:
'hallo'
,
bio
:
'welt'
}).
on
(
'success'
,
function
(
u
)
{
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
assert
.
eql
(
users
.
length
,
1
)
assert
.
eql
(
users
.
length
,
1
)
u
.
destroy
().
on
(
'success'
,
function
()
{
u
.
destroy
().
on
(
'success'
,
function
()
{
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
assert
.
eql
(
users
.
length
,
0
)
assert
.
eql
(
users
.
length
,
0
)
exit
(
function
(){})
exit
(
function
(){})
})
})
...
...
test/Model/find-findAll-all.js
View file @
f878edb
...
@@ -20,7 +20,7 @@ var initUsers = function(num, callback) {
...
@@ -20,7 +20,7 @@ var initUsers = function(num, callback) {
module
.
exports
=
{
module
.
exports
=
{
'all should return all created models'
:
function
(
exit
)
{
'all should return all created models'
:
function
(
exit
)
{
initUsers
(
2
,
function
(
_
,
User
)
{
initUsers
(
2
,
function
(
_
,
User
)
{
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
assert
.
eql
(
users
.
length
,
2
)
assert
.
eql
(
users
.
length
,
2
)
exit
(
function
(){})
exit
(
function
(){})
})
})
...
...
test/Model/save.js
View file @
f878edb
...
@@ -9,10 +9,10 @@ module.exports = {
...
@@ -9,10 +9,10 @@ module.exports = {
User
.
sync
({
force
:
true
}).
on
(
'success'
,
function
()
{
User
.
sync
({
force
:
true
}).
on
(
'success'
,
function
()
{
var
u
=
User
.
build
({
name
:
'hallo'
,
bio
:
'welt'
})
var
u
=
User
.
build
({
name
:
'hallo'
,
bio
:
'welt'
})
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
assert
.
eql
(
users
.
length
,
0
)
assert
.
eql
(
users
.
length
,
0
)
u
.
save
().
on
(
'success'
,
function
()
{
u
.
save
().
on
(
'success'
,
function
()
{
User
.
all
.
on
(
'success'
,
function
(
users
)
{
User
.
all
()
.
on
(
'success'
,
function
(
users
)
{
assert
.
eql
(
users
.
length
,
1
)
assert
.
eql
(
users
.
length
,
1
)
assert
.
eql
(
users
[
0
].
name
,
'hallo'
)
assert
.
eql
(
users
[
0
].
name
,
'hallo'
)
exit
(
function
(){})
exit
(
function
(){})
...
...
test/Sequelize/define.js
View file @
f878edb
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