Created
July 5, 2017 05:40
-
-
Save agilepoodle/baccc3260c3233d8cbfd11b2f0e576cb to your computer and use it in GitHub Desktop.
PostgreSQL jsonb operations
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
select id, jsonb_agg(selection_point - 'moduleId' - 'bottomSelectionPointParentId' || | |
jsonb_build_object('moduleGroupId', (select group_id from module where id=selection_point->>'moduleId'))) | |
into temporary education_vertical_top_selection_point_group_id | |
from (select id, jsonb_array_elements(document -> 'structure' -> 'vertical' -> 'topSelectionPoints') | |
as selection_point from education) tss group by id; | |
update education set document = | |
(jsonb_set(document, '{structure,vertical,topSelectionPoints}', | |
'[{"localId": "sis-group-deg-0001", "moduleId": "sis-deg-non-existent-v1", "bottomNaming": "NAMES_NOTHING", "topDegreeTitleUrn": null, "bottomAcceptanceType": "AUTOMATIC", "bottomSelectionPoints": [], "bottomSelectionPointParentId": null}]') | |
) where id = 'test-education-in-future'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment