Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-3452

Investigate changes in PM-3160: Expose the array index in a $map operation

    • Type: Icon: Investigation Investigation
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Tools and Replicator

      Original Downstream Change Summary

      New options will be added to $map, $filter and $reduce, allowing users to reference the array index of the element to which the operator's expression is currently being applied.

      Description of Linked Ticket

      Epic Summary

      Summary

      Extend $map, $filter, $reduce to expose the index of array element.

      Motivation

      Sometimes when working with arrays the logic depends on the position of the element. E.g. two-dimentional array represents values on the grid, and element index is a coordinate on X/Y axis; or user may want to select every other element of the array to create a sample for A/B test or parallel processing.
      It's pretty cumbersome to calculate position of the element today, so we'd like to introduce a simplified syntax for it.
      Example from Paul's book

      Documentation

      Product Description
      Scope
      Syntax
      Technical Design
      Docs Update

            Assignee:
            Unassigned Unassigned
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: