title: Mongoose update all object array
body: <p>Can I update all my object array at once?</p>
  <p>Here is my sample data</p>
  <pre><code>{
   &quot;_id&quot;: objectId(&quot;123&quot;),
   &quot;username&quot;: &quot;user&quot;,
   &quot;address_book&quot;: [{
      &quot;_id&quot;: objectId(&quot;456&quot;),
      &quot;isDefault&quot;: true,
   }, {
      &quot;_id&quot;: objectId(&quot;678&quot;),
      &quot;isDefault&quot;: true,
   }, {
      &quot;_id&quot;: objectId(&quot;321&quot;),
      &quot;isDefault&quot;: false,
   }] 
  }
  </code></pre>
  <p>Im trying to update all isDefault true to false.</p>
  <p>here is my code</p>
  <pre><code>User.updateMany(
   {
     _id: id,
     &quot;address_book.isDefault&quot;: 1,
   },
   {
     $set: { &quot;address_book.$.isDefault&quot;: 0 },
   },
   { multi: true }
  );
  </code></pre>
  <p>But this code only update the first addressbook. What I need is to update all</p>
  <p>Thank you</p>