title: delete an elemnt from an array inside another array with mongodb
body: <p>hello everyone i have a document of materiels where each document has an array of articles and each article has an array of details here's my collection data:</p>
  <pre><code>{
  &quot;_id&quot;: &quot;62f2404b42556d62e2939466&quot;,
  &quot;code&quot;: &quot;120K&quot;,
  &quot;designation&quot;: &quot;PIZZA&quot;,
  &quot;article&quot;: [
  {
  &quot;etat&quot;: &quot;Reçu&quot;,
  &quot;lot&quot;: &quot;&quot;,
  &quot;marque&quot;: &quot;Royal&quot;,
  &quot;fournisseur&quot;: &quot;maatalah&quot;,
  &quot;dateachat&quot;: &quot;2022-08-01T00:00:00.000Z&quot;,
  &quot;bc&quot;: null,
  &quot;bl&quot;: null,
  &quot;fc&quot;: null,
  &quot;quantite&quot;: 12,
  &quot;_id&quot;: &quot;62f25d001a035d017369e1f8&quot;,
  &quot;detail&quot;: [
  {
  &quot;serie&quot;: &quot;12&quot;,
  &quot;ddp&quot;: &quot;2023-01-01T00:00:00.000Z&quot;,
  &quot;_id&quot;: &quot;62f3986fe462b8a173c7d220&quot;
  },
  {
  &quot;serie&quot;: &quot;13&quot;,
  &quot;ddp&quot;: &quot;2023-03-01T00:00:00.000Z&quot;,
  &quot;_id&quot;: &quot;62f39cc1862c1bf5bc40157a&quot;
  }
  ]
  },
  {
  &quot;etat&quot;: &quot;Reçu&quot;,
  &quot;lot&quot;: &quot;&quot;,
  &quot;marque&quot;: &quot;margarita&quot;,
  &quot;fournisseur&quot;: &quot;&quot;,
  &quot;dateachat&quot;: &quot;2022-08-04T00:00:00.000Z&quot;,
  &quot;bc&quot;: null,
  &quot;bl&quot;: null,
  &quot;fc&quot;: null,
  &quot;quantite&quot;: 13,
  &quot;_id&quot;: &quot;62f25d041a035d017369e1fb&quot;,
  &quot;detail&quot;: [
  {
  &quot;serie&quot;: &quot;12345&quot;,
  &quot;ddp&quot;: &quot;2023-01-01T00:00:00.000Z&quot;,
  &quot;_id&quot;: &quot;62f281158a159e976c7c68d5&quot;
  }
  ]
  }
  ],
  &quot;qteglobal&quot;: 25,
  &quot;id&quot;: &quot;62f2404b42556d62e2939466&quot;
  }
  </code></pre>
  <p>i want to remove an element from the detail array here my express js code:</p>
  <pre><code>const { id, idarticle, iddetail } = req.params;
    const materiel = Materiel.findOneAndUpdate(
      { _id: id, &quot;article._id&quot;: idarticle, &quot;article.detail._id&quot;: iddetail },
      { $pull: { &quot;article.$.detail&quot;: { _id: iddetail } } },
  
      { new: true }
    );
  </code></pre>
  <p>there is no syntax error but the document it doesn't seem to be deleted.
  Can anyone help me please ? thank you</p>