Skip to content

Commit

Permalink
Merge pull request #3733 from dbkup/3.8.x
Browse files Browse the repository at this point in the history
fix erroneous change in #3730
  • Loading branch information
vkarpov15 committed Jan 4, 2016
2 parents c9ae762 + c112f98 commit e84ff06
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/aggregate.js
Expand Up @@ -80,8 +80,9 @@ Aggregate.prototype.bind = function (model) {
*/

Aggregate.prototype.append = function () {
var args = utils.args(arguments)
, arg;
var args = (1 === arguments.length && util.isArray(arguments[0]))
? arguments[0]
: utils.args(arguments);

if (!args.every(isOperator)) {
throw new Error("Arguments must be aggregate pipeline operators");
Expand Down Expand Up @@ -265,14 +266,12 @@ Aggregate.prototype.near = function (arg) {
*/

Aggregate.prototype.unwind = function () {
var args = (1 === arguments.length && util.isArray(arguments[0]))
? arguments[0]
: utils.args(arguments);
var args = utils.args(arguments);

return this.append.apply(this, args.map(function (arg) {
return { $unwind: '$' + arg };
}));
}
};

/**
* Appends a new $sort operator to this aggregate pipeline.
Expand Down

0 comments on commit e84ff06

Please sign in to comment.