Skip to content

Commit

Permalink
fix(cursor): allow $meta based sort when passing an array to sort()
Browse files Browse the repository at this point in the history
You may pass an object with a `$meta` key in place of the order parameter to `sort`.  The previous code would incorrectly reject this input as illegal.  See https://docs.mongodb.com/manual/reference/method/cursor.sort/#sort-metadata for documentation.
  • Loading branch information
dobesv authored and mbroadst committed Sep 5, 2018
1 parent bd80fb2 commit f93a8c3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ Cursor.prototype.sort = function(keyOrList, direction) {
value[1] = 1;
} else if (x[1] === 'desc') {
value[1] = -1;
} else if (x[1] === 1 || x[1] === -1) {
} else if (x[1] === 1 || x[1] === -1 || x[1].$meta) {
value[1] = x[1];
} else {
throw new MongoError(
Expand Down

0 comments on commit f93a8c3

Please sign in to comment.