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.

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.2
    • Component/s: Write Ops
    • Environment:
      platform: redhat 6.1. mongodb version: 2.0.2
    • Query
    • Fully Compatible

      { $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).

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

              Created:
              Updated:
              Resolved: