Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-6208

Comment on: "manual/reference/operator/update/pull.txt"

    XMLWordPrintableJSON

Details

    Description

      {
      _id: 1,
      results: [

      { item: "A", score: 5 }

      ,

      { item: "B", score: 8, comment: "Strongly agree" }

      ]
      }
      {
      _id: 2,
      results: [

      { item: "C", score: 8, comment: "Strongly agree" }

      ,

      { item: "B", score: 4 }

      ]
      }
      The following operation will remove from the results array all elements that contain both a score field equal to 8 and an item field equal to "B":

      db.survey.update(
      { },
      { $pull: { results:

      { score: 8 , item: "B" }

      } },

      { multi: true }

      )

      here the $pull operator does not remove result with

      {score:8,item:"B"}

      as $pull for array of documents requires all fields to match.

      Attachments

        Activity

          People

            Unassigned Unassigned
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              5 years, 17 weeks ago