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

not allowed to $push and $pop to same field in same update

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: 1.4.0
    • Fix Version/s: planned but not scheduled
    • Component/s: Write Ops
    • Labels:
      None

      Description

      Was just talking about #991 with Dwight and noticed that you can't workaround by doing $push / $pop to the same field on the same update, for example:

      > db.test.drop();
      false
      > db.test.save(

      { mylist: [1,2] }

      );
      > db.test.update( {}, { $push:

      { mylist: 3 }

      , $pop:

      { mylist: -1 }

      } );
      Field name duplication not allowed with modifiers

      Would be nice if this was permitted.

        Issue Links

          Activity

          Hide
          rwander Roman added a comment -

          +1

          Show
          rwander Roman added a comment - +1
          Hide
          ismetozalp Ismet Ozalp added a comment -

          This type of issues, always requires workarounds, most of the time these workarounds are ending up with ugly solutions.

          Just like this one these are all 5 year issues.
          https://jira.mongodb.org/browse/SERVER-1243
          https://jira.mongodb.org/browse/SERVER-1920
          Just like them i am going to watch this issue, hope for someday it will be fixed.

          +1

          Show
          ismetozalp Ismet Ozalp added a comment - This type of issues, always requires workarounds, most of the time these workarounds are ending up with ugly solutions. Just like this one these are all 5 year issues. https://jira.mongodb.org/browse/SERVER-1243 https://jira.mongodb.org/browse/SERVER-1920 Just like them i am going to watch this issue, hope for someday it will be fixed. +1
          Hide
          markbigler Mark Bigler added a comment -

          +1

          Show
          markbigler Mark Bigler added a comment - +1
          Hide
          blabergri@amadeus.com Benoit Labergri added a comment -

          Quit similar requierment for us : conditional $pull (on sub document field in the array) and non conditional $push in the same update on the same array.

          Show
          blabergri@amadeus.com Benoit Labergri added a comment - Quit similar requierment for us : conditional $pull (on sub document field in the array) and non conditional $push in the same update on the same array.
          Hide
          matt.kalan Matt Kalan added a comment -

          Ran into needing this capability today working with a user. They want to add results to multiple items in the array and it seems the best would be to pull off the original entries and then push the items with results added

          Show
          matt.kalan Matt Kalan added a comment - Ran into needing this capability today working with a user. They want to add results to multiple items in the array and it seems the best would be to pull off the original entries and then push the items with results added

            People

            • Votes:
              157 Vote for this issue
              Watchers:
              107 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since reply:
                6 weeks, 5 days ago
                Date of 1st Reply: