Jak*_*aur 16 sql postgresql supabase
我喜欢 Supabase,但我们的团队需要使用 PostgreSQL 提供的模式功能 - 不幸的是,到目前为止我们未能成功地使模式发挥作用。
其他信息:
我们已经尝试过:
我们创建了一个新模式并添加了对所有类型身份验证的访问(为什么全部?我们首先想到身份验证可能存在错误):
CREATE SCHEMA Brano;
GRANT USAGE ON SCHEMA Brano TO postgres, anon, authenticated, service_role, dashboard_user;
Run Code Online (Sandbox Code Playgroud)
通过此设置向 API 公开架构:
尝试了以下代码:
var options = {
schema: 'brano'
}
const supabaseUrl = 'supabaseUrl'
const supabaseKey = 'supabaseKey'
const supabaseClient = createClient(supabaseUrl, supabaseKey, options);
const { data, error } = await supabaseClient
.from('test_brano')
.insert([{
data: 123
}]);
Run Code Online (Sandbox Code Playgroud)
得到这个错误:
{
"message":"permission denied for table test_brano",
"code":"42501",
"details":null,
"hint":null
}
Run Code Online (Sandbox Code Playgroud)
我们尝试阅读的链接和文档(不幸的是我们没有让它以任何方式工作):
我们错过了什么吗?提前致谢!
Man*_*eli 14
除了前两个步骤之外,您还执行了以下操作:
\n授予用途:
\nCREATE SCHEMA Brano;\n\nGRANT USAGE \nON SCHEMA Brano \nTO postgres, anon, authenticated, service_role, dashboard_user;\n\nALTER DEFAULT PRIVILEGES IN SCHEMA brano\nGRANT ALL ON TABLES TO postgres, anon, authenticated, service_role, dashboard_user;\nRun Code Online (Sandbox Code Playgroud)\n在设置中公开架构:
\n\n缺少第三步:
\n授予操作能够插入/选择数据:
\nGRANT SELECT, INSERT, UPDATE, DELETE \nON ALL TABLES IN SCHEMA brano \nTO postgres, authenticated, service_role, dashboard_user, anon;\n\nGRANT USAGE, SELECT \nON ALL SEQUENCES IN SCHEMA brano \nTO postgres, authenticated, service_role, dashboard_user, anon;\nRun Code Online (Sandbox Code Playgroud)\n您必须为自定义架构中创建的每个新表再次设置这些授权。
\n然后您可以像示例中那样调用它:
\n const options = {\n db: { schema: \'brano\' }\n };\n const supabase = createClient(supabaseUrl, SUPABASE_KEY, options)\n const d = new Date(2018, 11, 24, 10, 33, 30, 0);\n const { data, error } = await supabase\n .from(\'test_brano\')\n .insert([\n { data: 3, created_at: d }\n ])\n console.log(data)\n if (error) {\n console.log("error getting results");\n throw error;\n }\nRun Code Online (Sandbox Code Playgroud)\n const options = {\n schema: \'brano\'\n }\n const supabase = createClient(supabaseUrl, SUPABASE_KEY, options)\n const d = new Date(2018, 11, 24, 10, 33, 30, 0);\n const { data, error } = await supabase\n .from(\'test_brano\')\n .insert([\n { data: 3, created_at: d }\n ])\n console.log(data)\n if (error) {\n console.log("error getting results");\n throw error;\n }\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
6889 次 |
| 最近记录: |