title: Remove element from jsonb array
body: <p>I have the following jsonb. From the array pages I would like to remove the element called 'pageb'. The solutions offered in similar questions are not working for me.</p>
  
  <pre><code>'{
    "data": {
      "id": "a1aldjfg3f",
      "pages": [
        {
          "type": "pagea"
        },
        {
          "type": "pageb"
        }                                
      ],
      "activity": "test"
    }
  }'
  </code></pre>
  
  <p>My script right now looks like this. It doesnt return any error but the elements won't be removed.</p>
  
  <pre><code>  UPDATE database
    SET reports = jsonb_set(reports, '{data,pages}', (reports-&gt;'data'-&gt;'pages') - ('{"type":"pageb"}'), true)
    WHERE reports-&gt;'data'-&gt;'pages'  @&gt; '[{"type":"pageb"}]';
  </code></pre>