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

"{ $pull : { field : _value } }" support removes the first occurrences of value from field, if field is an array.

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.0.2
    • Fix Version/s: None
    • Component/s: Write Ops
    • Labels:
    • Environment:
      platform: redhat 6.1. mongodb version: 2.0.2
    • Backwards Compatibility:
      Fully Compatible

      Description

      { $pull :

      { field : _value }

      } will removes all occurrences of value from field, if field is an array.
      In my project, I need { $pull :

      { field : _value }

      } removes the first occurrences of value from field.
      For example:
      document:

      { "_id":"123", "boys":[ {"name":"jhon"}

      ,

      {"name":"jhon"}

      ,

      {"name":"gavin"}

      ]
      }
      As you see, the array "boys" has three elements, and the first is same
      to the second. If I do {$pull:{"name":"jhon"}}, then the first and second element will be removed.
      Actually, I just want to remove the first element(left the second element and the third element).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-server-query Backlog - Query Team (Inactive)
              Reporter:
              genliu gavinliu
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: