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

$insert and $remove for arrays (currently $set, $unset, $push, and $pull are insufficient)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Write Ops
    • Labels:
      None

      Description

      Arrays currently have a number of bizarre behaviors (especially in PHP) and limited support for manipulation makes this difficult to work around. The following additional functions would help:

      $insert - atomic insertion into an array at an index.
      Currently the only options are $push (which only works if you are adding to the end) and overwriting the entire array.

      $remove - remove elements from an array BY INDEX, without leaving "null" entries.
      Currently the only universally safe option is to overwrite the entire array. $unset leaves null entries, $pull works only if the element is known to be unique, and $unset followed by $pull null only works if the array is known to not contain nulls (also because $unset + $pull requires two separate operations, it is clunky and non-atomic (array contains null for a period of time)).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-query Backlog - Query Team (Inactive)
              Reporter:
              bugslayer John Crenshaw
              Participants:
              Votes:
              6 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: