create or replace function public.call_embed_edge_function()
returns trigger
language plpgsql
as $$
begin
perform
net.http_post(
url:=supabase_url() || '/functions/v1/embed',
headers:= jsonb_build_object(
'Content-Type', 'application/json',
'Authorization', current_setting('request.headers')::json->>'authorization'
),
body := jsonb_build_object(
'chunk_id', new.id,
'chunk_content', new.content
)
);
return null;
end;
$$;
CREATE or replace TRIGGER on_chunk_insert
AFTER INSERT ON public.document_chunks
FOR EACH ROW
EXECUTE PROCEDURE public.call_embed_edge_function();
create or replace function public.call_embed_edge_function()
returns trigger
language plpgsql
as $$
begin
perform
net.http_post(
url:=supabase_url() || '/functions/v1/embed',
headers:= jsonb_build_object(
'Content-Type', 'application/json',
'Authorization', current_setting('request.headers')::json->>'authorization'
),
body := jsonb_build_object(
'chunk_id', new.id,
'chunk_content', new.content
)
);
return null;
end;
$$;
CREATE or replace TRIGGER on_chunk_insert
AFTER INSERT ON public.document_chunks
FOR EACH ROW
EXECUTE PROCEDURE public.call_embed_edge_function();