[CSHARP-1608] Aggregation should have a $reverseArray expression. Created: 17/Mar/16  Updated: 27/May/22  Resolved: 23/Aug/16

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: None
Fix Version/s: 2.4

Type: New Feature Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Craig Wilson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-23029 Aggregation should have a $reverseArr... Closed
is depended on by DRIVERS-297 Aggregation Framework Support for 3.4 Closed
Epic Link: MongoDB 3.4
Server Compat: 3.3

 Description   

Syntax

{$reverseArray: <expression which evaluates to an array>}

Examples

Input

{_id: 0, a: [1, 2, 3]}

Pipeline

db.coll.aggregate([{
    $project: {
        reversed: {$reverseArray: "$a"}
    }
}])

Output

{_id: 0, reversed: [3, 2, 1]}

Additional Notes

  • Can be used in combination with $reduce to yield the equivalent of a $foldR.
  • Returns null if input is nullish.
  • Errors if input is not an array or nullish.

Original Description

Aggregation should support an $reverseArray expression, which accepts as input an expression that evaluates to an array, and outputs the reversed version of the array. Throws an error if the input is not an array or nullish.



 Comments   
Comment by Githook User [ 29/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1608: Added support for $reverseArray.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/12d18e14d6493a4726461b1673885ba62f342696

Comment by Githook User [ 24/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1608: Added support for $reverseArray.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/12d18e14d6493a4726461b1673885ba62f342696

Comment by Githook User [ 21/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1608: Added support for $reverseArray.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/bdeabce087670396cca8b8cf6a10de48aed5a694

Comment by Githook User [ 16/Sep/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1608: Added support for $reverseArray.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/8952fe5b1845ab805b4b510b526cc518754cfef0

Comment by Githook User [ 31/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1608: Added support for $reverseArray.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/6ef2b5fe64ba5e01a8045847aacef68f4bcd4662

Comment by Githook User [ 29/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1608: Added support for $reverseArray.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/910548669dba4ec51db76ca60cc5e52e3e989b21

Comment by Githook User [ 23/Aug/16 ]

Author:

{u'username': u'craiggwilson', u'name': u'Craig Wilson', u'email': u'craiggwilson@gmail.com'}

Message: CSHARP-1608: Added support for $reverseArray.
Branch: v2.4.x
https://github.com/mongodb/mongo-csharp-driver/commit/2b6ddcf9bd6fb85d85af03ecd2a10c5fe17f5cf7

Generated at Wed Feb 07 21:40:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.