Create a gist now

Instantly share code, notes, and snippets.

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