title: Update MongoDB collection with values from an array
body: <p>I need to update all documents in a MongoDB collection with values from an array.</p>
  
  <p>Say for example i have the documents in below schema in mongo:</p>
  
  <pre><code>{
   "key":"value",
   "key2":"value2"
  }
  </code></pre>
  
  <p>I have an array : ["test","test2"]</p>
  
  <p>I want to create an iterator through the array, so the "keyN" key in all docs in the collections are updated with either "test" or "test2"</p>
  
  <pre><code>{
    "key":"value",
    "key2":"value2",
    "keyN":"test"
  }
  {
    "key":"value",
    "key2":"value2",
    "keyN":"test2"
  }
  {
    "key":"value",
    "key2":"value2",
    "keyN":"test"
  }
  </code></pre>
  
  <p>How do I do this? I tried using the forEach, but I am not able to figure out the way to create an iterator on the array. </p>