【发布时间】:2021-10-09 03:57:27
【问题描述】:
我无法更新启用角色级别策略的行
我的表有如下插入和更新的行级策略:
create policy "Allow individual insert access" on public.quotes for insert with check ( auth.uid() = created_by );
create policy "Allow individual update access" on public.quotes for update with check ( auth.uid() = created_by );
一旦用户登录,我的插入功能就可以正常工作:
export const addQuote = async (user_id, content) => {
try {
let body = await supabase
.from("quotes")
.insert([{ created_by: user_id, content: content }]);
return body;
} catch (error) {
console.log("error", error);
}
};
我的更新功能在没有行级策略的情况下工作正常:
export const updateQuote = async (quote_id, user_id, new_content) => {
try {
let body = await supabase
.from("quotes")
.update([{ created_by: user_id, content: new_content }])
.eq("id", quote_id);
return body;
} catch (error) {
console.log("error in updateQuote", error);
}
};
但开启 RLS 时响应为 404 且行未更新。
我在这里错过了什么?
【问题讨论】:
标签: row-level-security supabase