The main idea is to allow users create database objects through Supabase client libraries. To get a similar feel to firestore.
This can already be done by using meta/[meta_triggers]) + PostgREST.
Some examples with postgrest-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'}
])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'
})let { status } = await meta
.from('view')
.insert([
{ schema_name: 'public', name : 'teens', query: 'select * from people where age between 13 and 19'}
])-
Doing this for Supabase clients would require:
- installing the meta extension
- adding
metatodb-schema - using the
service_roleformetacalls - 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