Unable to $Pull array by 2nd element in array

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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 }
      )
      

        1. students.json
          52 kB
          Suman Chakraborty

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

              Created:
              Updated:
              Resolved: