Skip to content

Instantly share code, notes, and snippets.

@agilepoodle
Created July 5, 2017 05:40
Show Gist options
  • Save agilepoodle/baccc3260c3233d8cbfd11b2f0e576cb to your computer and use it in GitHub Desktop.
Save agilepoodle/baccc3260c3233d8cbfd11b2f0e576cb to your computer and use it in GitHub Desktop.

Revisions

  1. agilepoodle created this gist Jul 5, 2017.
    11 changes: 11 additions & 0 deletions jsonb_operations.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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';