title: Mongoose document update- selected objects in array - with $in operator
body: <p>My schema is as below.</p>
  
  <p>Customer: {</p>
  
  <pre><code>orders: [{
       ...
      status: 'Pending'
          ...
  }]
  </code></pre>
  
  <p>}</p>
  
  <p>I have a list of order ids whose which are delivered to the customer. So I need to change the Status to closed. This is my simple requirement. I have my below code, which updates the status 'closed' only for the first order id in the OrderIdList.</p>
  
  <p>orderIdList = ["54899c0cbdde6b281e9aaa22","54899c28bdde6b281e9aaa23","54899c2abdde6b281e9aaa24","54899c2cbdde6b281e9aaa25"]</p>
  
  <pre><code>Customer.update({
      'orders._id': {
          $in: orderIdList
      }
  }, {
      '$set': {
          'orders.$.status': 'Closed'
      }
  }, {
      multi: true,
      upsert: true
  }, function(err, rows) {
      console.log("error");
      console.log(err);
      console.log("rows updated");
      console.log(rows);
  });
  </code></pre>
  
  <p>Only one row is updated. for the orderId "54899c0cbdde6b281e9aaa22"</p>
  
  <p>Why is it not updating for all the order Ids. Please suggest me the solution.</p>
  
  <p>Thanks in advance.</p>