- 日本語にも対応した全文検索インデッ
クスエンジンpgroonga対応
- Database Functionを使って簡単に検
索
全文検索
create index pgroonga_content_index
on posts
using pgroonga (body)
with (tokenizer='TokenMecab');
final List data = await supabase
.rpc('search_posts', params: {
'query': query,
});
- 特定のテーブルでのイベントに対し
て発火
- 他のテーブルのデータを書き換えた
り、Webhookを発火したりできる
データベーストリガー
create or replace function public.handle_likes()
returns trigger
language plpgsql
security definer set search_path = public
as $$
declare
notifier_id uuid;
begin
select user_id
into notifier_id
from public.posts
where id = new.post_id
and user_id != new.user_id;
if found then
insert into public.notifications (type,
notifier_id, actor_id, entity_id)
values ('like', notifier_id, new.user_id,
new.post_id);
end if;
return new;
end;
$$;