Skip to content

Instantly share code, notes, and snippets.

@geobabbler
Created March 7, 2017 20:28
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 geobabbler/341793e4eb88e9f112c2605226791a40 to your computer and use it in GitHub Desktop.
Save geobabbler/341793e4eb88e9f112c2605226791a40 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION public.sample_notify()
RETURNS trigger AS
$BODY$
DECLARE
BEGIN
PERFORM pg_notify('actions', '{"type": "Feature", "geometry": ' ||
st_asgeojson(NEW.shape) ||
',"properties": {"message": "' ||
'insert' || '",' ||
'"schema": "' || TG_TABLE_SCHEMA || '",' ||
'"table": "' || TG_TABLE_NAME || '",' ||
'"id": "' || NEW.id || '"' ||
'}}' );
RETURN new;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION public.sample_notify()
OWNER TO postgres;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment