Last active
January 13, 2026 09:46
-
-
Save steve-chavez/c7e99bc5d8e7acba7166dbf108f7e18f to your computer and use it in GitHub Desktop.
Revisions
-
steve-chavez revised this gist
Jan 13, 2026 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -50,12 +50,13 @@ console.log(body); ### Creating an RLS policy ```js let { body, error } = await meta .from('policy') .insert([{ schema_name: "public", relation_name: "todos", name: "owners can see their todos", command: "all" using: "(select auth.uid()) = owner", check: "(select auth.uid()) = owner", }]) -
steve-chavez revised this gist
Jan 13, 2026 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -111,7 +111,6 @@ console.log(body); ### TODO - Creating indexes - Creating fk constraints - Creating table privileges -
steve-chavez revised this gist
Jan 13, 2026 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## Metarest The main idea is to allow users create database objects through Supabase client libraries. To get a similar feel to [firestore](https://firebase.google.com/docs/firestore/data-model). @@ -56,7 +56,8 @@ let { body, error } = await meta .insert([{ schema_name: "public", relation_name: "todos", name: "owners can see their todos", using: "(select auth.uid()) = owner", check: "(select auth.uid()) = owner", }]) ``` -
steve-chavez revised this gist
Jan 13, 2026 . 1 changed file with 27 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,44 +7,59 @@ This can already be done by using [meta](https://github.com/aquametalabs/meta)/[ Some examples with postgrest-js: ### Initializing the clients ```js const supabase = require('@supabase/postgrest-js') const meta = new supabase.PostgrestClient('http://localhost:3000', {schema : 'meta'}) const pub = new supabase.PostgrestClient('http://localhost:3000', {schema : 'public'}) ``` ### Creating a table and columns ```js let { status } = await meta .from('table') .insert([{ schema_name: 'public', name : 'todos', rowsecurity: true}]) let { status } = await meta .from('column') .insert([ { schema_name: 'public', relation_name : 'todos', name : 'id', type_name : 'integer' } , { schema_name: 'public', relation_name : 'todos', name : 'body', type_name : 'text' } , { schema_name: 'public', relation_name : 'todos', name : 'owner', type_name : 'uuid', "default": "auth.uid()" } ]) let { body, error } = await pub .from('todos') .insert([ { id: 1, body: "create a todo" } , { id: 2, body: "pat yourself on back" } ]) let { body, error } = await pub .from('todos') .select('*') console.log(body); [ { id: 1, body: "create a todo" }, { id: 2, body: "pat yourself on back" } ] ``` ### Creating an RLS policy ```sql let { body, error } = await meta .from('policy') .insert([{ schema_name: "public", relation_name: "todos", name: "owners can see their todos", using: "(select auth.uid()) = owner" }]) ``` ### Creating a function ```js -
steve-chavez revised this gist
Sep 27, 2022 . No changes.There are no files selected for viewing
-
steve-chavez revised this gist
Dec 1, 2020 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,12 @@ Some examples with postgrest-js: ### Creating a table and columns ```js const supabase = require('@supabase/postgrest-js') const meta = new supabase.PostgrestClient('http://localhost:3000', {schema : 'meta'}) const pub = new supabase.PostgrestClient('http://localhost:3000', {schema : 'public'}) let { status } = await meta .from('table') .insert([{ schema_name: 'public', name : 'people' }]) -
steve-chavez revised this gist
Dec 1, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ This can already be done by using [meta](https://github.com/aquametalabs/meta)/[ Some examples with postgrest-js: ### Creating a table and columns ```js let { status } = await meta -
steve-chavez revised this gist
Dec 1, 2020 . 1 changed file with 30 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,8 +10,6 @@ Some examples with postgrest-js: ### Creating a table plus columns ```js let { status } = await meta .from('table') .insert([{ schema_name: 'public', name : 'people' }]) @@ -21,8 +19,24 @@ let { status } = await meta .insert([ { schema_name: 'public', relation_name : 'people', name : 'id', type_name : 'integer' } , { schema_name: 'public', relation_name : 'people', name : 'age', type_name : 'integer' } ]) let { body, error } = await pub .from('people') .insert([ { id: 1, age: 40 } , { id: 2, age: 50 } , { id: 3, age: 60} , { id: 4, age: 13} , { id: 5, age: 19} ]) let { body, error } = await pub .from('people') .select('*') console.log(body); [ { id: 1, age: 40 }, { id: 2, age: 50 }, { id: 3, age: 60 }, { id: 4, age: 13 }, { id: 5, age: 19 } ] ``` ### Creating a function @@ -36,6 +50,12 @@ let { status } = await meta return_type: 'integer', language: 'sql', definition: 'select a - b' }) let { body, error } = await pub .rpc('subtract', {a: 63, b: 13}) console.log(body); 50 ``` ### Creating a view @@ -46,6 +66,13 @@ let { status } = await meta .insert([ { schema_name: 'public', name : 'teens', query: 'select * from people where age between 13 and 19'} ]) let { body, error } = await pub .from('teens') .select('*') console.log(body); [ { id: 4, age: 13 }, { id: 5, age: 19 } ] ``` ### Comments -
steve-chavez revised this gist
Nov 30, 2020 . 1 changed file with 9 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,8 +58,12 @@ let { status } = await meta - Some operations could be wrapped by supabase-js to give better DX. - The meta extension is pure SQL. So it can be installed on any provider. ### TODO - Creating a POLICY - Creating indexes - Creating fk constraints - Creating table privileges - Create a ROLE -
steve-chavez revised this gist
Nov 30, 2020 . No changes.There are no files selected for viewing
-
steve-chavez revised this gist
Nov 30, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ The main idea is to allow users create database objects through Supabase client libraries. To get a similar feel to [firestore](https://firebase.google.com/docs/firestore/data-model). This can already be done by using [meta](https://github.com/aquametalabs/meta)/[meta_triggers](https://github.com/aquametalabs/meta_triggers) + PostgREST. Some examples with postgrest-js: -
steve-chavez created this gist
Nov 30, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ FROM postgres RUN metaDependencies="git \ ca-certificates \ build-essential" \ && apt-get update \ && apt-get install -y --no-install-recommends ${metaDependencies} \ && apt-get install -y build-essential \ && apt-get install make \ && cd /tmp \ && git clone https://github.com/aquametalabs/meta.git \ && cd meta \ && make \ && make install && cd /tmp \ && git clone https://github.com/aquametalabs/meta_triggers.git \ && cd meta_triggers \ && make \ && make install #CREATE EXTENSION hstore SCHEMA public; #CREATE EXTENSION meta; #CREATE EXTENSION meta_triggers; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ ## Metarest(work in progress) The main idea is to allow users create database objects through Supabase client libraries. To get a similar feel to [firestore](https://firebase.google.com/docs/firestore/data-model). This can already be done by using [meta](https://github.com/aquametalabs/meta)/[meta_triggers]) + PostgREST. Some examples with postgrest-js: ### Creating a table plus columns ```js let meta = new supabase.PostgrestClient('http://localhost:3000', {schema : 'meta'}) let { status } = await meta .from('table') .insert([{ schema_name: 'public', name : 'people' }]) let { status } = await meta .from('column') .insert([ { schema_name: 'public', relation_name : 'people', name : 'id', type_name : 'integer' } , { schema_name: 'public', relation_name : 'people', name : 'age', type_name : 'integer' } , { schema_name: 'public', relation_name : 'people', name : 'score', type_name : 'integer'} ]) ``` ### Creating a function ```js let { status } = await meta .from('function') .insert({ schema_name: 'public', name : 'subtract', parameters: ['a integer', 'b integer'], return_type: 'integer', language: 'sql', definition: 'select a - b' }) ``` ### Creating a view ```js let { status } = await meta .from('view') .insert([ { schema_name: 'public', name : 'teens', query: 'select * from people where age between 13 and 19'} ]) ``` ### Comments - Doing this for Supabase clients would require: - installing the meta extension - adding `meta` to `db-schema` - using the `service_role` for `meta` calls - adding an event trigger for automatic postgrest schema cache update - Some operations could be wrapped by supabase-js to give better DX. - TODO: - Creating a POLICY - Creating indexes - Creating fk constraints - Creating table privileges