Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4588

aggregation: add option to $unwind to emit array index

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.8
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Fully Compatible
    • Quint 9 09/18/15

      There may be times when the index of an array element is interesting. $unwind
      could provide an option to emit this. For example

      instead of just

      db.runCommand({ aggregate:"c", pipeline:[
          { $unwind: "$arrayField"}
      ]});
      

      consider also supporting something like this:

      db.runCommand({ aggregate:"c", pipeline:[
          { $unwind: { path: "$arrayField", includeArrayIndex: boolean }}
      ]});
      

      The effect of this is the same except that it also adds a new field index
      to the output which is assigned the index of the array element.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            dan@mongodb.com Daniel Pasette (Inactive)
            Votes:
            19 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:
              Resolved: