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

Unable to $Pull array by 2nd element in array

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      Students Json attached herewith has been imported into students collection, has 200 documents.

      When trying to delete single array element from and array by second element (score),
      shell gives message: Updated 1 existing record(s) in 1ms

      But actually no change happens inside db and the array element stays there.

      Below commands not working:

      db.students.update(
        { '_id': 0  },
        { $pull: { scores: { type: 'homework', score: 6.67617606065462 } } },
        { multi: true }
      )
      db.students.update(
        { '_id': 0 },
        { $pull: { scores: { type: "homework",score:6.67617606065462} } },
        { multi: true }
      )
       
      But, below command works when trying to delete by 1st element of the array
      db.students.update(
        { '_id': 0  },
        { $pull: { scores: { type: 'homework' } } },
        { multi: true }
      )
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            tataiermail Suman Chakraborty
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: