Skip to content

Instantly share code, notes, and snippets.

@saicitus
Created March 7, 2017 21:37
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 saicitus/1710f220a61eaf833a8359aef0d80d47 to your computer and use it in GitHub Desktop.
Save saicitus/1710f220a61eaf833a8359aef0d80d47 to your computer and use it in GitHub Desktop.
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