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 6dfe8a70
authored
Jul 08, 2015
by
overlookmotel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Standardize `findAndCount` arguments
1 parent
7831e0b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
lib/model.js
lib/model.js
View file @
6dfe8a7
...
...
@@ -1394,14 +1394,14 @@ Model.prototype.count = function(options) {
* @return {Promise<Object>}
* @alias findAndCountAll
*/
Model
.
prototype
.
findAndCount
=
function
(
findOptions
)
{
// testhint options:1
if
(
findOptions
!==
undefined
&&
!
_
.
isPlainObject
(
findO
ptions
))
{
Model
.
prototype
.
findAndCount
=
function
(
options
)
{
if
(
options
!==
undefined
&&
!
_
.
isPlainObject
(
o
ptions
))
{
throw
new
Error
(
'The argument passed to findAndCount must be an options object, use findById if you wish to pass a single primary key value'
);
}
var
self
=
this
// no limit, offset, order, attributes for the options given to count()
,
countOptions
=
_
.
omit
(
_
.
clone
(
findO
ptions
),
[
'offset'
,
'limit'
,
'order'
,
'attributes'
]);
,
countOptions
=
_
.
omit
(
_
.
clone
(
o
ptions
),
[
'offset'
,
'limit'
,
'order'
,
'attributes'
]);
conformOptions
(
countOptions
,
this
);
...
...
@@ -1438,7 +1438,7 @@ Model.prototype.findAndCount = function(findOptions) { // testhint options:1
rows
:
[]
};
}
return
self
.
findAll
(
findO
ptions
).
then
(
function
(
results
)
{
return
self
.
findAll
(
o
ptions
).
then
(
function
(
results
)
{
return
{
count
:
count
||
0
,
rows
:
(
results
&&
Array
.
isArray
(
results
)
?
results
:
[])
...
...
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