Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poboisvert/duproprio_supabase_rpc
DuProprio to SupaBase for analytics PoC
https://github.com/poboisvert/duproprio_supabase_rpc
nextjs13 postgres rpc supabase
Last synced: 10 days ago
JSON representation
DuProprio to SupaBase for analytics PoC
- Host: GitHub
- URL: https://github.com/poboisvert/duproprio_supabase_rpc
- Owner: poboisvert
- Created: 2023-04-10T19:39:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-23T19:50:36.000Z (5 months ago)
- Last Synced: 2024-06-23T20:29:46.510Z (5 months ago)
- Topics: nextjs13, postgres, rpc, supabase
- Language: Python
- Homepage: https://devsarticles.com/wp-content/uploads/2024/03/Supabase-With-React.png
- Size: 228 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Supabase update or insert (w/JSON)
## .env.local
```
# Development settings
SUPABASE_URL=
SUPABASE_KEY=```
## SUPABASE FUNCTION
I was having trouble to find documentation on how to save a JSON with RPC function of Supabase
```
CREATE OR REPLACE FUNCTION update_listing_base(page_slug TEXT, address TEXT, data jsonb)
RETURNS void
LANGUAGE plpgsql
AS $$
BEGIN
IF EXISTS (SELECT FROM listing WHERE slug=page_slug and is_active is True) THEN
UPDATE listing
SET is_active = True,
updated_at = NOW()
WHERE slug = page_slug;
ELSE
INSERT into listing(slug, address, data) VALUES (page_slug, address, data::JSON);
END IF;
END;
$$;
```![preview](1.png)
And you can run the query in the interface to validate
![preview](2.png)