Skip to content

Instantly share code, notes, and snippets.

@eliashussary
Last active March 19, 2018 15:45
Show Gist options
  • Save eliashussary/d45d7fb9c22a98e34a482edccc9f1559 to your computer and use it in GitHub Desktop.
Save eliashussary/d45d7fb9c22a98e34a482edccc9f1559 to your computer and use it in GitHub Desktop.
Postgres Example of adding and removing keys from json
update "listingSubscriptions"
set criteria = (jsonb_set(criteria::jsonb, '{moveInDateParsed}', '["",""]'));
update "listingSubscriptions"
set "criteria" = (criteria::jsonb - 'moveInDate')::json;
update "listingSubscriptions"
set criteria = (jsonb_set(criteria::jsonb, '{listPrice}', to_jsonb('{0,6000}'::int[])))
where (criteria->'listPrice')::jsonb = '["",""]';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment