title: Update Nested JSON Components in Postgres
body: <p>I have a table that looks like this:</p>
  
  <pre><code>parts
  id     name       children
  1      Part 1     [{id: 2, name: 'Part 2'}]
  2      Part 2     []
  </code></pre>
  
  <p>Let's say I change the name of <code>Part 2</code> to <code>Part X</code></p>
  
  <p>I want to update both the main data, and the nested children data.</p>
  
  <p>I did this:</p>
  
  <p><code>UPDATE parts SET name = 'Part X' WHERE id=2</code></p>
  
  <p>Now how do I also update the JSON data to match?</p>
  
  <p>I thought this was good syntax, but it's not:</p>
  
  <p><code>UPDATE parts SET [{name: 'Part X'}] WHERE json_agg([id: 2])</code></p>
  
  <p>Also this is <code>Postgres v10</code></p>