存储函数: rpc()

您可以将 存储函数称为“远程过程调用”。

这是一种奇特的说法,您可以将一些逻辑放入数据库中,然后从任何地方调用它。当逻辑很少改变时,它特别有用——比如密码重置和更新。

final res = await supabase
  .rpc('hello_world')
  .execute();

Examples

调用存储函数

这是调用 Postgres 函数的示例

final res = await supabase
  .rpc('hello_world')
  .execute();

带参数

final res = await supabase
  .rpc('echo_city', params: { 'name': 'The Shire' })
  .execute();

带 count 选项

您可以指定一个计数选项来获取行计数以及您的数据。对于count选项允许值是 null, exact, planned and estimated.

final res = await supabase
  .rpc('hello_world')
  .execute(count: CountOption.exact);

results matching ""

    No results matching ""