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 7a7f2d60
authored
Apr 10, 2013
by
Jochem Maas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename Model "findAndCount" method to "findAndCountAll"
1 parent
e1dbc3a4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
lib/dao-factory.js
spec-jasmine/dao-factory.spec.js
lib/dao-factory.js
View file @
7a7f2d6
...
@@ -249,7 +249,7 @@ module.exports = (function() {
...
@@ -249,7 +249,7 @@ module.exports = (function() {
return
this
.
QueryInterface
.
rawSelect
(
this
.
tableName
,
options
,
'count'
)
return
this
.
QueryInterface
.
rawSelect
(
this
.
tableName
,
options
,
'count'
)
}
}
DAOFactory
.
prototype
.
findAndCount
=
function
(
options
)
{
DAOFactory
.
prototype
.
findAndCount
All
=
function
(
options
)
{
var
self
=
this
var
self
=
this
,
copts
=
Utils
.
_
.
extend
({},
options
||
{})
,
copts
=
Utils
.
_
.
extend
({},
options
||
{})
...
...
spec-jasmine/dao-factory.spec.js
View file @
7a7f2d6
...
@@ -227,7 +227,7 @@ describe('DAOFactory', function() {
...
@@ -227,7 +227,7 @@ describe('DAOFactory', function() {
})
})
})
})
describe
(
'findAndCount'
,
function
()
{
describe
(
'findAndCount
All
'
,
function
()
{
var
users
=
[],
fullcount
=
3
var
users
=
[],
fullcount
=
3
beforeEach
(
function
()
{
beforeEach
(
function
()
{
...
@@ -238,7 +238,7 @@ describe('DAOFactory', function() {
...
@@ -238,7 +238,7 @@ describe('DAOFactory', function() {
it
(
"handles where clause [only]"
,
function
()
{
it
(
"handles where clause [only]"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
User
.
findAndCount
({
where
:
"id != "
+
users
[
0
].
id
}).
success
(
function
(
info
)
{
User
.
findAndCount
All
({
where
:
"id != "
+
users
[
0
].
id
}).
success
(
function
(
info
)
{
expect
(
info
.
count
).
toEqual
(
fullcount
-
1
)
expect
(
info
.
count
).
toEqual
(
fullcount
-
1
)
expect
(
Array
.
isArray
(
info
.
rows
)).
toBeTruthy
()
expect
(
Array
.
isArray
(
info
.
rows
)).
toBeTruthy
()
expect
(
info
.
rows
.
length
).
toEqual
(
fullcount
-
1
)
expect
(
info
.
rows
.
length
).
toEqual
(
fullcount
-
1
)
...
@@ -249,7 +249,7 @@ describe('DAOFactory', function() {
...
@@ -249,7 +249,7 @@ describe('DAOFactory', function() {
it
(
"handles where clause with ordering [only]"
,
function
()
{
it
(
"handles where clause with ordering [only]"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
User
.
findAndCount
({
where
:
"id != "
+
users
[
0
].
id
,
order
:
'id ASC'
}).
success
(
function
(
info
)
{
User
.
findAndCount
All
({
where
:
"id != "
+
users
[
0
].
id
,
order
:
'id ASC'
}).
success
(
function
(
info
)
{
expect
(
info
.
count
).
toEqual
(
fullcount
-
1
)
expect
(
info
.
count
).
toEqual
(
fullcount
-
1
)
expect
(
Array
.
isArray
(
info
.
rows
)).
toBeTruthy
()
expect
(
Array
.
isArray
(
info
.
rows
)).
toBeTruthy
()
expect
(
info
.
rows
.
length
).
toEqual
(
fullcount
-
1
)
expect
(
info
.
rows
.
length
).
toEqual
(
fullcount
-
1
)
...
@@ -262,7 +262,7 @@ describe('DAOFactory', function() {
...
@@ -262,7 +262,7 @@ describe('DAOFactory', function() {
// at time of writing (v1.6.0) Sequelize does not seem to support 'offset' on it's own consistently (goes wrong for PostGRES and SQLite)
// at time of writing (v1.6.0) Sequelize does not seem to support 'offset' on it's own consistently (goes wrong for PostGRES and SQLite)
it("handles offset", function() {
it("handles offset", function() {
Helpers.async(function(done) {
Helpers.async(function(done) {
User.findAndCount({offset: 1}).success(function(info) {
User.findAndCount
All
({offset: 1}).success(function(info) {
expect(info.count).toEqual(fullcount)
expect(info.count).toEqual(fullcount)
expect(Array.isArray(info.rows)).toBeTruthy()
expect(Array.isArray(info.rows)).toBeTruthy()
expect(info.rows.length).toEqual(fullcount - 1)
expect(info.rows.length).toEqual(fullcount - 1)
...
@@ -273,7 +273,7 @@ describe('DAOFactory', function() {
...
@@ -273,7 +273,7 @@ describe('DAOFactory', function() {
*/
*/
it
(
"handles limit"
,
function
()
{
it
(
"handles limit"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
User
.
findAndCount
({
limit
:
1
})
/*.on('sql', console.log)*/
.
success
(
function
(
info
)
{
User
.
findAndCount
All
({
limit
:
1
})
/*.on('sql', console.log)*/
.
success
(
function
(
info
)
{
expect
(
info
.
count
).
toEqual
(
fullcount
)
expect
(
info
.
count
).
toEqual
(
fullcount
)
expect
(
Array
.
isArray
(
info
.
rows
)).
toBeTruthy
()
expect
(
Array
.
isArray
(
info
.
rows
)).
toBeTruthy
()
expect
(
info
.
rows
.
length
).
toEqual
(
1
)
expect
(
info
.
rows
.
length
).
toEqual
(
1
)
...
@@ -284,7 +284,7 @@ describe('DAOFactory', function() {
...
@@ -284,7 +284,7 @@ describe('DAOFactory', function() {
it
(
"handles offset and limit"
,
function
()
{
it
(
"handles offset and limit"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
User
.
findAndCount
({
offset
:
1
,
limit
:
1
}).
success
(
function
(
info
)
{
User
.
findAndCount
All
({
offset
:
1
,
limit
:
1
}).
success
(
function
(
info
)
{
expect
(
info
.
count
).
toEqual
(
fullcount
)
expect
(
info
.
count
).
toEqual
(
fullcount
)
expect
(
Array
.
isArray
(
info
.
rows
)).
toBeTruthy
()
expect
(
Array
.
isArray
(
info
.
rows
)).
toBeTruthy
()
expect
(
info
.
rows
.
length
).
toEqual
(
1
)
expect
(
info
.
rows
.
length
).
toEqual
(
1
)
...
...
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