Created
March 7, 2017 21:37
-
-
Save saicitus/1710f220a61eaf833a8359aef0d80d47 to your computer and use it in GitHub Desktop.
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
CREATE OR REPLACE FUNCTION filter (children jsonb[]) | |
RETURNS jsonb[] | |
AS $$ | |
DECLARE | |
i jsonb; | |
result jsonb[]; | |
BEGIN | |
FOR i IN SELECT * FROM jsonb_array_elements(children) | |
LOOP | |
IF i.value -> 'name' != 'null'::jsonb THEN | |
result=array_append(result, i); | |
END IF; | |
END LOOP; | |
return result; | |
END; | |
$$ language plpgsql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment