Skip to content

Instantly share code, notes, and snippets.

@AlxGolubev
Created June 26, 2017 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlxGolubev/61498b2f74a5b9b572803e2dd5bd55a6 to your computer and use it in GitHub Desktop.
Save AlxGolubev/61498b2f74a5b9b572803e2dd5bd55a6 to your computer and use it in GitHub Desktop.
How to create a new key in existing record with JSONB field in Postgres
UPDATE users SET preferences = jsonb_set(to_jsonb(preferences), '{some_preference}'::text[], 'true'::jsonb, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment