Add a way to "unwind" fields in a document.

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Example function:

      db.coll.insert({id: 'foo', a: 100, b: 200, c: 300, d: {e: 400, f:500}})
      db.coll.aggregate([
        {$docUnwind: {id: 0}},  // syntax similar to $project for whitelisting or blacklisting which fields to unwind
      ])
      {id: 'foo', f_name: 'a', f_value: 100}
      {id: 'foo', f_name: 'b', f_value: 200}
      {id: 'foo', f_name: 'c', f_value: 300}
      {id: 'foo', f_name: 'd.e', f_value: 400}
      {id: 'foo', f_name: 'd.f', f_value: 500}
      

      In short, it will take the fields in a document, and unwind a portion of them into name, value pairs, making a separate document for each.

      One use case for this is collecting statistics across a dynamic list of fields.

            Assignee:
            Unassigned
            Reporter:
            Rod Adams (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: