title: Trim string values of whitespace, from an array of sub-documents with string field
body: <p>On all documents of my collection I want to perform a <code>$trim</code> operation to a specific field of an object that is in an array. </p>
  
  <p>Example:</p>
  
  <pre><code>{
    "_id" : ObjectId("53857680f7b2eb611e843a32"),
    "company": Testcompany
    "customer" :
        "name": Testuser,
        "addresses" : [
              {
                  "_id" : ObjectId("5d6d2f96e3fdc8001077ac6c"), 
                  "street" : "Teststreet.   ", 
                  "houseNr" : "133", 
              },
              {
                  "_id" : ObjectId("5d6d2f96e3fdc8001077ac7b"), 
                  "street" : "    Simplestreet.   ", 
                  "houseNr" : "12", 
              }
          ], 
  }
  </code></pre>
  
  <p>In the example, I want to <code>$trim</code> all values of the field: <code>"customer.addresses.street"</code></p>
  
  <p>To answer the upcoming questions:</p>
  
  <ol>
  <li>I know the article you mentioned (<a href="https://stackoverflow.com/questions/23903785/removing-white-spaces-leading-and-trailing-from-string-value">Removing white spaces (leading and trailing) from string value</a>) but theres no example how to do it within an array.</li>
  </ol>
  
  <p>My problem is, how to access the attributes within an array, heres the example of plain values:</p>
  
  <p>[{ $set: { category: { $trim: { input: "$category" } } } }],</p>
  
  <ol start="2">
  <li>Yes, I want to update the values of all documents within the collection</li>
  </ol>