title: mongodb remove array from the collection using index or any method
body: <p>I have the following collection :</p>
  <p><a href="https://i.stack.imgur.com/Zf6ad.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zf6ad.png" alt="order" /></a></p>
  <p>I use the following code to remove the element of the orderList array that matches the orderId. But it doesn't work.</p>
  <p>Order.update({&quot;_id&quot;:ObjectId(userOrder._id)},{&quot;$pull&quot;:{&quot;orderList&quot;:{orderId: &quot;WPN-1645691337205&quot;}}});</p>
  <p>and I tried the following code as well</p>
  <p>Order.update({&quot;_id:&quot;:ObjectId(&quot;621741dcd40da387489093c2&quot;)}, {$unset : {&quot;orderList.0&quot; : 1 }});</p>
  <p>Order.update({&quot;_id:&quot;:ObjectId(&quot;621741dcd40da387489093c2&quot;)}, {$pull:{&quot;orderList&quot;:null}});</p>
  <p>Thanks,
  Jo</p>