Last active
October 23, 2015 09:35
-
-
Save Reimerei/9e3bf2a00b3f57e7184d to your computer and use it in GitHub Desktop.
Postgres jsonb: remove key from all entries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function | |
CREATE FUNCTION jsonb_merge(JSONB, JSONB) | |
RETURNS JSONB AS $$ | |
WITH json_union AS ( | |
SELECT * FROM JSONB_EACH($1) | |
UNION ALL | |
SELECT * FROM JSONB_EACH($2) | |
) SELECT JSON_OBJECT_AGG(key, value)::JSONB FROM json_union; | |
$$ LANGUAGE SQL; | |
# Command | |
Update he_user_meta set value = jsonb_merge(value, '{"game_state_version":null}'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment