Func and Triggers
Hi, kind people! Trying to find out - how to write functions and triggers in Supabase. Can anybody help me with finding solution?
I have a table named "records" and couple of buckets with some assets. My goal is to write the trigger on record deletion to delete related assets - they have record id in the name.
I wrote this kind of thing:
CREATE OR REPLACE FUNCTION public.storage_assets_deletion()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
begin
DELETE FROM
storage.objects
WHERE name LIKE '%' "concat" records.id "concat" '%';
return null;
end;
$function$
"concat" is ||
but it throws an error - PostgrestError(details: nil, hint: nil, code: Optional("42P01"), message: "missing FROM-clause entry for table "records"")
What am I doing wrong? And what to do to achieve my goal?
I have a table named "records" and couple of buckets with some assets. My goal is to write the trigger on record deletion to delete related assets - they have record id in the name.
I wrote this kind of thing:
CREATE OR REPLACE FUNCTION public.storage_assets_deletion()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
begin
DELETE FROM
storage.objects
WHERE name LIKE '%' "concat" records.id "concat" '%';
return null;
end;
$function$
"concat" is ||
but it throws an error - PostgrestError(details: nil, hint: nil, code: Optional("42P01"), message: "missing FROM-clause entry for table "records"")
What am I doing wrong? And what to do to achieve my goal?