title: Update fields of array subdocuments with one request
body: <p>I have the following document in a collection:</p>
  <pre><code>{
      _id: 'test',
      values: [
          { foo: 1, bar: [&lt;very big array&gt;] },
          { foo: 4, bar: [&lt;very big array&gt;] },
          { foo: 3, bar: [&lt;very big array&gt;] }
      ]
  }
  </code></pre>
  <p>I want to update all <code>values[].foo</code> values at once with a pre-calculated array. For performances reasons, I don't want to read the <code>values[].bar</code> arrays and since <code>values</code> can contains many elements, I'm searching a way to do it with only one request (if possible).</p>
  <p>For example, I want to write something like this:</p>
  <pre><code>db.collection.updateOne({ _id: 'test' }, { $set: { 'values[].foo': [2, 3, 4] }});
  </code></pre>
  <p>And the result would be the following:</p>
  <pre><code>{
      _id: 'test',
      values: [
          { foo: 2, bar: [&lt;very big array&gt;] },
          { foo: 3, bar: [&lt;very big array&gt;] },
          { foo: 4, bar: [&lt;very big array&gt;] }
      ]
  }
  </code></pre>
  <p>But I don't know how i must write my update request.</p>
  <p>I'm using MongoDB 4.0 and i don't have access to 4.2 features.</p>