Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listen to notification #147

Open
saqib556612 opened this issue Nov 17, 2020 · 3 comments
Open

listen to notification #147

saqib556612 opened this issue Nov 17, 2020 · 3 comments

Comments

@saqib556612
Copy link

Hello i am using postgress on cloud and i created triggerfunction and trigger in pgAdmin.
Here is my trigger function

CREATE FUNCTION public.row_notifiy_n()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF
AS $BODY$
BEGIN
PERFORM pg_notify(
'rowChanged',
json_build_object(
'operation', TG_OP,
'record', row_to_json(new)
)::text
);
Return new;
END;
$BODY$;

ALTER FUNCTION public.row_notifiy_n()
OWNER TO "abc";

and trigger is

CREATE TRIGGER notify
AFTER INSERT OR DELETE OR UPDATE
ON public."Logs"
FOR EACH ROW
EXECUTE PROCEDURE public.row_notifiy_n();

ALTER TABLE public."Logs"
ENABLE ALWAYS TRIGGER notify;

How i can listen this in flutter

@IsemicolonI
Copy link

IsemicolonI commented Feb 5, 2024

Apparently, in old versions, you could listen to notifications with connection.notifications.listen(), but with the replacement of Connection with PostgreSQLConnection, this feature no longer exists in created connection and no document exist for notification listening.
I also filed this issue and am waiting for help

@isoos
Copy link
Collaborator

isoos commented Feb 5, 2024

@IsemicolonI
Copy link

I read the source code almost 1 hour ago and realized how to do this, but it is better to put an example in Example so that there is no need to read the API reference or source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants