title: MongoDB query to update fields with same name
body: <p>I'm using <code>mongodb version v3.4.2</code></p>
  
  <p>I have a collection with one document.</p>
  
  <p>The document has a complex(not standard) structure that I don't know.</p>
  
  <p>The structure of the document is something like this</p>
  
  <pre><code>{
      "time": 9281
      "object_1": [
          { "time": 8372 },
          { "time": 3234 }
      ],
      "object_2": {
          "time": 2928
      }
  }
  </code></pre>
  
  <p>I need to change the values of all fields with name <code>"time"</code>.</p>
  
  <p>Can I do this with a single/multiple mongo query?</p>
  
  <p>I tried with :</p>
  
  <pre><code>db.collection.update({}, {$set: {time: 999}})
  db.collection.updateMany({}, {$set: {time: 999}})
  </code></pre>
  
  <p>but only top level occurrencies are updated with the new value.</p>
  
  <p>After the document has been updated with the query, this should be the result:</p>
  
  <pre><code>{
      "time":999
      "object_1":[{"time":999},{"time":999}]
      "object_2":{"time":999}
  }
  </code></pre>