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.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • 2.0.2
    • None
    • Write Ops
    • platform: redhat 6.1. mongodb version: 2.0.2
    • Query
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: