-
-
Notifications
You must be signed in to change notification settings - Fork 1
Persons
URL: https://gqfktgknxmguhxgkajat.supabase.co
Key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYyMDc2MTg0NCwiZXhwIjoxOTM2MzM3ODQ0fQ.xEa_GuNypFdHSdQVLCd0beoL_v8jhWKjSTypX6kn-sg
create policy "Public persons are viewable by everyone." on persons for select using (true);
create policy "Persons can update their own information." on persons for update using (auth.uid() = user_id);
https://gqfktgknxmguhxgkajat.supabase.co/rest/v1/persons?count&and=(death.not.is.null)
https://gqfktgknxmguhxgkajat.supabase.co/rest/v1/persons?count&and=(death.is.null)
https://gqfktgknxmguhxgkajat.supabase.co/rest/v1/rpc/persons
- Alive
- Dead
CREATE OR REPLACE FUNCTION persons()
RETURNS TABLE(alive bigint, dead bigint) AS $$
BEGIN
RETURN QUERY
SELECT
SUM(1) FILTER (WHERE death IS NULL) AS alive,
SUM(1) FILTER (WHERE death IS NOT NULL) AS dead
FROM persons;
END
$$ LANGUAGE plpgsql;
CREATE SERVER x2
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host 'db.snoulbshaqjnlgwfevpz.supabase.co', port '5432', dbname 'postgres');
CREATE USER MAPPING FOR local_user
SERVER x2
OPTIONS (user 'foreign_user', password 'password');
DROP FOREIGN TABLE foreign_countries;
CREATE FOREIGN TABLE foreign_countries (
id integer NOT NULL,
country json
)
SERVER x2
OPTIONS (schema_name 'public', table_name 'countries');
Persons