title: Append a string to the end of an existing field in MongoDB
body: <p>I have a document with a field containing a very long string. I need to concatenate another string to the end of the string already contained in the field.</p>
  
  <p>The way I do it now is that, from Java, I fetch the document, extract the string in the field, append the string to the end and finally update the document with the new string.</p>
  
  <p>The problem: The string contained in the field is very long, which means that it takes time and resources to retrieve and work with this string in Java. Furthermore, this is an operation that is done several times per second.</p>
  
  <p><strong>My question</strong>: Is there a way to concatenate a string to an existing field, without having to fetch (<code>db.&lt;doc&gt;.find()</code>) the contents of the field first? In reality all I want is (<code>field.contents += new_string</code>).</p>
  
  <p>I already made this work using Javascript and <code>eval</code>, but as I found out, MongoDB locks the database when it executes javascript, which makes the overall application even slower.</p>