title: Mongodb - Concatenate multiple nested arrays and convert to a string
body: <p>I have the following documents</p>
  <pre><code>{&quot;_id&quot;: &quot;1&quot;, &quot;posts&quot;: [{&quot;text&quot;: &quot;all day long I dream about&quot;, &quot;datetime&quot;: &quot;123&quot;}, {&quot;text&quot;: &quot;all day long &quot;, &quot;datetime&quot;: &quot;321&quot;}]}
  {&quot;_id&quot;: &quot;1&quot;, &quot;posts&quot;: [{&quot;text&quot;: &quot;all day long I dream about&quot;, &quot;datetime&quot;: &quot;123&quot;}, {&quot;text&quot;: &quot;all day long &quot;, &quot;datetime&quot;: &quot;8888&quot;}, {&quot;text&quot;: &quot;I became very hungry after watching this movie...&quot;, &quot;datetime&quot;: &quot;8885&quot;}]}
  </code></pre>
  <p>I wish to concatenate the <strong>text</strong> fields into a new field and the <strong>datetime</strong> field into a new field while also joining the arrays elements into a string in a way that the new field will be as follows</p>
  <pre><code>{&quot;_id&quot;: &quot;1&quot;, &quot;text&quot;: &quot;all day long I dream about, all day long &quot;, &quot;datetime&quot;: &quot;123, 321&quot;}
  {&quot;_id&quot;: &quot;1&quot;, &quot;text&quot;: &quot;all day long I dream about, all day long ,I became very hungry after watching this movie... &quot;, &quot;datetime&quot;: &quot;123, 8888, 8885&quot;}
  </code></pre>
  <p>What's the best way of doing that directly on Mongodb server? Is there such way?</p>