diff options
Diffstat (limited to 'jstests/aggregation/unwind_sort.js')
| -rw-r--r-- | jstests/aggregation/unwind_sort.js | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/jstests/aggregation/unwind_sort.js b/jstests/aggregation/unwind_sort.js deleted file mode 100644 index 858320bec0d..00000000000 --- a/jstests/aggregation/unwind_sort.js +++ /dev/null @@ -1,27 +0,0 @@ -// Test that we can sort on fields, produces by unwind - -const coll = db.agg_unwind_sort; -coll.drop(); -assert.commandWorked(coll.insertOne({a: [3, 4, 5]})); -assert.commandWorked(coll.insertOne({a: [1, 2]})); - -let result = coll.aggregate([{$unwind: "$a"}, {$sort: {a: 1}}]).toArray(); -assert.eq([1, 2, 3, 4, 5], result.map(function(z) { - return z.a; -})); -result = coll.aggregate([{$unwind: "$a"}, {$sort: {a: -1}}]).toArray(); -assert.eq([5, 4, 3, 2, 1], result.map(function(z) { - return z.a; -})); -result = - coll.aggregate([{$unwind: {path: "$a", includeArrayIndex: "i"}}, {$sort: {i: 1}}]).toArray(); -assert.eq([NumberLong(0), NumberLong(0), NumberLong(1), NumberLong(1), NumberLong(2)], - result.map(function(z) { - return z.i; - })); -result = - coll.aggregate([{$unwind: {path: "$a", includeArrayIndex: "i"}}, {$sort: {i: -1}}]).toArray(); -assert.eq([NumberLong(2), NumberLong(1), NumberLong(1), NumberLong(0), NumberLong(0)], - result.map(function(z) { - return z.i; - })); |
