Skip to content

Instantly share code, notes, and snippets.

@steve-chavez
Last active January 13, 2026 09:46
Show Gist options
  • Select an option

  • Save steve-chavez/c7e99bc5d8e7acba7166dbf108f7e18f to your computer and use it in GitHub Desktop.

Select an option

Save steve-chavez/c7e99bc5d8e7acba7166dbf108f7e18f to your computer and use it in GitHub Desktop.

Revisions

  1. steve-chavez revised this gist Jan 13, 2026. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -50,12 +50,13 @@ console.log(body);

    ### Creating an RLS policy

    ```sql
    ```js
    let { body, error } = await meta
    .from('policy')
    .insert([{
    schema_name: "public", relation_name: "todos",
    .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",
    }])
  2. steve-chavez revised this gist Jan 13, 2026. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -111,7 +111,6 @@ console.log(body);

    ### TODO

    - Creating a POLICY
    - Creating indexes
    - Creating fk constraints
    - Creating table privileges
  3. steve-chavez revised this gist Jan 13, 2026. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Metarest(work in progress)
    ## 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"
    using: "(select auth.uid()) = owner",
    check: "(select auth.uid()) = owner",
    }])
    ```

  4. steve-chavez revised this gist Jan 13, 2026. 1 changed file with 27 additions and 12 deletions.
    39 changes: 27 additions & 12 deletions README.md
    Original 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:

    ### Creating a table and columns
    ### 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 : 'people' }])
    .insert([{ schema_name: 'public', name : 'todos', rowsecurity: true}])

    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 : '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('people')
    .insert([ { id: 1, age: 40 } , { id: 2, age: 50 } , { id: 3, age: 60} , { id: 4, age: 13} , { id: 5, age: 19} ])
    .from('todos')
    .insert([ { id: 1, body: "create a todo" } , { id: 2, body: "pat yourself on back" } ])

    let { body, error } = await pub
    .from('people')
    .from('todos')
    .select('*')

    console.log(body);
    [
    { id: 1, age: 40 },
    { id: 2, age: 50 },
    { id: 3, age: 60 },
    { id: 4, age: 13 },
    { id: 5, age: 19 }
    { 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
  5. steve-chavez revised this gist Sep 27, 2022. No changes.
  6. steve-chavez revised this gist Dec 1, 2020. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original 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' }])
  7. steve-chavez revised this gist Dec 1, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original 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 plus columns
    ### Creating a table and columns

    ```js
    let { status } = await meta
  8. steve-chavez revised this gist Dec 1, 2020. 1 changed file with 30 additions and 3 deletions.
    33 changes: 30 additions & 3 deletions README.md
    Original 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 meta = new supabase.PostgrestClient('http://localhost:3000', {schema : 'meta'})

    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' }
    , { schema_name: 'public', relation_name : 'people', name : 'score', 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
  9. steve-chavez revised this gist Nov 30, 2020. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions README.md
    Original 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.

    - TODO:
    - Creating a POLICY
    - Creating indexes
    - Creating fk constraints
    - Creating table privileges
    - 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
  10. steve-chavez revised this gist Nov 30, 2020. No changes.
  11. steve-chavez revised this gist Nov 30, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original 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]) + PostgREST.
    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:

  12. steve-chavez created this gist Nov 30, 2020.
    23 changes: 23 additions & 0 deletions Dockerfile
    Original 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;
    65 changes: 65 additions & 0 deletions README.md
    Original 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