不要怂,就是干,撸起袖子干!

Commit 6dfe8a70 by overlookmotel

Standardize `findAndCount` arguments

1 parent 7831e0b6
Showing with 4 additions and 4 deletions
...@@ -1394,14 +1394,14 @@ Model.prototype.count = function(options) { ...@@ -1394,14 +1394,14 @@ Model.prototype.count = function(options) {
* @return {Promise<Object>} * @return {Promise<Object>}
* @alias findAndCountAll * @alias findAndCountAll
*/ */
Model.prototype.findAndCount = function(findOptions) { // testhint options:1 Model.prototype.findAndCount = function(options) {
if (findOptions !== undefined && !_.isPlainObject(findOptions)) { if (options !== undefined && !_.isPlainObject(options)) {
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'); 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 var self = this
// no limit, offset, order, attributes for the options given to count() // no limit, offset, order, attributes for the options given to count()
, countOptions = _.omit(_.clone(findOptions), ['offset', 'limit', 'order', 'attributes']); , countOptions = _.omit(_.clone(options), ['offset', 'limit', 'order', 'attributes']);
conformOptions(countOptions, this); conformOptions(countOptions, this);
...@@ -1438,7 +1438,7 @@ Model.prototype.findAndCount = function(findOptions) { // testhint options:1 ...@@ -1438,7 +1438,7 @@ Model.prototype.findAndCount = function(findOptions) { // testhint options:1
rows: [] rows: []
}; };
} }
return self.findAll(findOptions).then(function(results) { return self.findAll(options).then(function(results) {
return { return {
count: count || 0, count: count || 0,
rows: (results && Array.isArray(results) ? results : []) rows: (results && Array.isArray(results) ? results : [])
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!