JSONB - sgml/signature GitHub Wiki

  • Get length of a column bar in table foo JSONB array:

      SELECT jsonb_array_length(bar)
      FROM foo
      where baz = 'bop'
    
  • Find a string in a JSONB array:

      SELECT 1
      FROM jsonb_each_text(tags) AS j(key, value)
      WHERE j.value ~ 'already'
    
  • Find/Replace JSON Text

      UPDATE foo 
      SET jsonb_column = replace(jsonb_column::text, 'CALIFA', 'Khalifa')::jsonb
      WHERE foo_uuid = '7a0be34a-9095-4a4e-b07b-337a090342c7'
    

References