title: mongoose update a field in an object of array
body: <p>I'm using mongoose findOneAndUpdate()
  In mongodb i have a database with objects inside an array look like this:</p>
  
  <p>patients model</p>
  
  <pre><code>{
          "_id" : ObjectId("5cb939a3ba1d7d693846136c"),
          "myArray" : [
              {
                  "name" : "PW6178281935-20190425",
                  "treatment" : "beauty",
                  "value" : 0 &lt;- i want to update this
              },
              {
                  "name" : "PW6178281935-24142444",
                  "treatment" : "muscle",
                  "value" : 0
              }
          ] 
  },
   {
          "_id" : ObjectId("5cc123a3bb2d3123a932475f"),
          "myArray" : [
              {
                  "name" : "PW6178281935-43535555",
                  "treatment" : "helps",
                  "value" : 0 
              },
              {
                  "name" : "PW6178281935-92732978",
                  "treatment" : "documents",
                  "value" : 0
              }
          ] 
  }
  </code></pre>
  
  <p>i want to update value of an object with treatment = "beauty" of _id = "5cb939a3ba1d7d693846136c"</p>
  
  <p>in schema "value" has default value of 0</p>
  
  <p>i had tried with this but the value doesn't get update</p>
  
  <pre><code>patients.findOneAndUpdate({$and:[{'patients._id' : 5cb939a3ba1d7d693846136c}, {'myArray.treatment' : beauty}]}, { $set: { 'myArray.$.value': 424214 } }, { new: true });
  </code></pre>
  
  <p>Am I doing something wrong?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>The answer from Frank Rose was right , the reason arrayFilters doesn't work for me because the project i was working on using mongoose 4.4 which doesn't support arrayFilters of mongoDB yet.If you want to use arrayFilters with your project please use mongoose version 5 or later.After i upgrade to mongoose 5.5 i was able to edit the object</p>