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

Inserting a unique value into a specific position in an array

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • Labels:
      None

      Inserting an item of any type into a specific postion into existing array structure

      Currently $push only appends data to an array.
      But there is no function to insert an array into a specific postion.

      Example data (Python array)

      Before:
      [ [Item1, 0, 0], [Item2, 0, 0].. ] # Array items inside an array

      Command for example can be
      { '$insert':

      { 'myArray.1': [item3, 0,0 ] }

      } # At position 1 of the myArray

      Result:
      [ [Item1, 0,0], [Item3, 0,0], [Item2, 0,0] ]

      $push is out of question as the data should be inserted to keep a order of the items.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jan.rie Jan Riechers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: