title: How can we delete an array index from a mongodb database with some conditions?
body: <p>The following is the data in my mongodb database collection.</p>
  <pre><code>[   
      {
              _id: 6097ba8b64d60c653b810c28,
              pincode: 711104,
              mailID: [ 
                   {
                      mail: &quot;email1@gmail.com&quot;,
                      dateOfReg: &quot;10-05-2021&quot;
                   },
                   {
                      mail: &quot;email2@gmail.com&quot;,
                      dateOfReg: &quot;09-05-2021&quot;
                   }
              ]   
      },
      {
              _id: 6097bb7c64d60c653b810c29,
              pincode: 841231,
              mailID: [ 
                  {
                      mail: &quot;email3@gmail.com&quot;,
                      dateOfReg: &quot;09-05-2021&quot;
                  },
                  {
                      mail: &quot;email4@gmail.com&quot;,
                      dateOfReg: &quot;08-05-2021&quot;
                  }
              ]   
      },   
      {
              _id: 6097bbaa64d60c653b810c2a,
              pincode: 711105,
              mailID: [ 
                  {
                      mail: &quot;email6@gmail.com&quot;,
                      dateOfReg: &quot;07-05-2021&quot;
                  }
              ]   
      } 
  ]
  </code></pre>
  <p>And I want to delete the indexes of array <strong>mailID</strong> in which <strong>dateOfReg: &quot;09-05-2021&quot;</strong></p>
  <p>I have tried to solve this problem with following command which I found in mongodb docs.</p>
  <pre><code>vaccinenotifier.update({},
      {
        $pull: {
          mailID: {
            $elemMatch: {
              dateOfReg : &quot;10-05-2021&quot;
            }
          }
        }
      },
      { multi: true })
  </code></pre>
  <p>But its not doing the job. Please help me to solve this issue.</p>