title: MongoDB Panache Updating nested objects within Document
body: <p>I have a model which looks like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>{
    "projectName": "MyFirstProject",
    "projectId": "1234",
    "testCaseList": [
      {
        "testCaseName": "TestCase1",
        "steps": [
          {
            "Action": "Click on this",
            "Result": "pass"
          },
          {
            "Action": "Click on that",
            "Result": "pass"
          }
        ]
      },
      {
        "testCaseName": "TestCase2",
        "steps": [
          {
            "Action": "Click on him",
            "Result": "pass"
          },
          {
            "Action": "Click on her",
            "Result": "pass"
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>However, as this is a nested object, I am having difficulties updating it using the method:</p>
  
  <pre class="lang-java prettyprint-override"><code>default PanacheUpdate update(String update, Object... params)
  </code></pre>
  
  <p>I am using Repository Pattern and below is my code snippet:</p>
  
  <pre class="lang-java prettyprint-override"><code>List&lt;TestCase&gt; newTestCaseList = ...;
  update("testCaseList", newTestCaseList).where("projectId=?1",projectId);
  </code></pre>
  
  <p>which actually throws the following error:</p>
  
  <pre class="lang-java prettyprint-override"><code>org.bson.json.JsonParseException: JSON reader was expecting ':' but found ','.
  at org.bson.json.JsonReader.readBsonType(JsonReader.java:149)
      at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:82)
      at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
      at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:101)
      at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
      at org.bson.BsonDocument.parse(BsonDocument.java:63)
      at io.quarkus.mongodb.panache.runtime.MongoOperations.executeUpdate(MongoOperations.java:634)
      at io.quarkus.mongodb.panache.runtime.MongoOperations.update(MongoOperations.java:629)
  </code></pre>
  
  <p><strong>My Current Approach</strong></p>
  
  <p>What currently works for me is to use <code>default void update(Entity entity)</code> instead when updating nested objects.
  This however presents a few considerations:</p>
  
  <ol>
  <li>Extra code is required to fetch the entire document, parse through, and update the required fields</li>
  <li>Since <code>update(Entity entity)</code> works on a document level, it will also update unchanged parts of the document, which isn't ideal.</li>
  </ol>