title: How may I update an array that's in a MongoDB using Spring?
body: <p>I'm trying to update database information from some information I get from a Thymeleaf powered page. Basically each page is constructed using a single document from MongoDB. Now I'd like to allow some users to change this page, since the actual page is not that complex, I was giving a shot to this JavaScript plugin that would create text area divs and send them to server via Ajax (<a href="http://www.dyve.net/jquery/?editable" rel="nofollow noreferrer">http://www.dyve.net/jquery/?editable</a>). </p>
  
  <p>Since the document has only unique fields, I can set the field id in the html to the name of the mongodb field, like product-description. I can send the id through and the update is really simple: </p>
  
  <pre><code>public boolean updateValueWithKey(String id, String k, String v) {
      Criteria c = Criteria.where(id).is(id);
      Query q = new Query().addCriteria(c);
      Update u = u.set(k, v);
      WriteResult w = operations.updateFirst(q, u, clazz);
      return w.wasAcknowledged();
  }
  </code></pre>
  
  <p>Where id is the document id code, k is the field name (key) and v the value. </p>
  
  <p>But I realized that one particular part of the document has an array, but I don't understand how can I update a particular field of an array. </p>
  
  <p>The Update class has a inner class called PushOperatorBuilder with a method called atPosition, which the docs mention that: "Forces values to be added at the given {@literal position}."</p>
  
  <p>But I really don't understand how to use that, any attempt to reach that method from the instantiated Update object just gave me errors. </p>
  
  <p>Help?</p>